-
Notifications
You must be signed in to change notification settings - Fork 5
/
typedef2.c
37 lines (29 loc) · 648 Bytes
/
typedef2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef char PASSPORT[15];
typedef char PHONE_NBR[15];
typedef struct {
char name[100];
int age;
PASSPORT passport;
PHONE_NBR phone;
} PERSON;
void fillPersonData( PERSON * person, const char * name, int age )
{
if ( strlen( name ) < 100 ) {
strcpy( person->name, name );
}
person->age = age;
}
int main( int argc, const char * argv[] )
{
PERSON person;
if ( argc < 3 ) {
printf( "Indique nombre y edad por favor\n" );
return 1;
}
fillPersonData( &person, argv[1], atoi( argv[2] ) );
printf( "Name = %s, age = %d\n", person.name, person.age );
return 0;
}