Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C programming example for a Person struct and typedef (from ECE 2534)
//Example code from class on defining and using a struct //-------myStruct.h--------------- // This would normally be in an include file #ifndef __MYSTRUCT #define __MYSTRUCT typedef struct __Person { char name[30]; char address[50]; int zipcode; } Person; #endif //-------main begins here--------- #include <stdio.h> #include <string.h> // need this for C string functions // helper function to print out Person struct printPerson(Person *myPerson) { printf("Name: %s\n",myPerson->name); printf("Address:\n%s\n",myPerson->address); printf("Zip Code: %5d\n",myPerson->zipcode); } int main(void) { Person student; printf("Example code for a struct, from class.\n\n"); strcpy(student.name,"Joe Nerdy"); strcpy(student.address,"302 Whittemore\nECE Department\nVirginia Tech"); student.zipcode = 87544; printPerson(&student); return 0; }
run
|
edit
|
history
|
help
0
pointer**
qsort
pattern 12
1
A_141205_CadenaValorNumerico
binary to txt
SAI_1-4.c
Goodone for understanding array passing
Binary to Integer (C)
1.4 Thread IDs