Created
March 23, 2024 05:35
-
-
Save kilroyjones/8fee9ff87a34a2e05eb5b1107ec44127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example in posts on Rust borrow system | |
#include <stdio.h> | |
typedef struct { | |
int age; | |
int is_oldest; | |
} Person; | |
int main() { | |
Person people[] = { | |
{10, 0}, | |
{8, 0}, | |
{14, 0} | |
}; | |
int length = sizeof(people) / sizeof(people[0]); | |
Person *oldest = &people[0]; | |
for (int i = 1; i < length; i++) { | |
if (people[i].age > oldest->age) { | |
oldest = &people[i]; | |
} | |
} | |
oldest->is_oldest = 1; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment