Created
February 17, 2016 21:25
-
-
Save guyhughes/52a3feaf2c5f79db4ee9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| struct studentRecord | |
| { | |
| char lastName[100]; | |
| char firstName[100]; | |
| long studentId; | |
| double mark; | |
| }; | |
| typedef struct studentRecord studentRecord_t; | |
| void initStu( char *last, char *first, long studentId, double mark, studentRecord_t *stu ) | |
| { | |
| strcpy(stu->firstName, first); | |
| strcpy(stu->lastName, last); | |
| stu->studentId = studentId; | |
| stu->mark = mark; | |
| return; | |
| } | |
| void printStu ( studentRecord_t *stu ) | |
| { | |
| printf("%li %s %s %f\n",stu->studentId,stu->firstName,stu->lastName,stu->mark); | |
| } | |
| int main ( void ) | |
| { | |
| studentRecord_t students[100]; | |
| int i; | |
| char first[2]; | |
| first[1] = '\0'; | |
| for(i=0; i <100; ++i){ | |
| first[0] = 'A'+i%26; | |
| initStu("Jones",first,10000+i+i%5*100,i%11, &students[i]); | |
| } | |
| for(i=0; i <100; ++i) | |
| printStu(&students[i]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment