Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
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
Please
log in
to post a comment.
18BCE2182 ASSESS_1 Q1-4
Part 1: Draw Arts (square)
20171103_factorial
Finding the second largets value v0.5
Fibonacci multiplos de 3 y menores que 30
B_14118_RestasSucesivas
14th Feb Project v0.3
Primer avance de lista enlazadas
150108_recursividadFactorial
otro avance de pregunta 2
Please log in to post a comment.