Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
lab 12 v1
//gcc 5.4.0 #include <stdio.h> #include <string.h> #include <limits.h> //typedef struct{ // char first_name[20]; // char last_name[20]; // }name typedef struct{ char person_name[40]; int age; }person; int getoldest(person persons[],int N){ int Maxage=0; int i; for(i=0;i<N;i++){ if(persons[i].age>Maxage) Maxage=i; } printf("%d %s\n",persons[Maxage].age,persons[Maxage].person_name); return 0; } int main(void) { printf("Please input array size\n"); int N; scanf("%d",&N); person *persons; persons=(struct person*)malloc(N*sizeof(person)); persons[0].age=10; persons[1].age=5; strcpy(persons[0].person_name,"Jacob"); strcpy(persons[1].person_name,"Jane"); getoldest(persons,N); return 0; }
run
|
edit
|
history
|
help
0
Example of scanf and basic integer manipulation - with function call
Deadlock
fgets and basic string manipulation
4
Score
223780
Lab 9 v1
B_141125_MenorMayor
CO Assignment 1 Question 1
Vereinfachung