- #include <stdio.h>
- #include <string.h>
- struct employee
- { int id;
- char name[50];
- }e1; //declaring e1 variable for structure
- int main( )
- {
- //store first employee information
- e1.id=101;
- strcpy(e1.name, "Soniya");//copying string into char array
- //printing first employee information
- printf( "employee 1 id : %d\n", e1.id);
- printf( "employee 1 name : %s\n", e1.name);
- return 0;
- }
Output:
employee 1 id : 101 employee 1 name : Soniya
No comments:
Post a Comment