Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- #include<Windows.h>
- #define STUDENTTOTAL 1
- typedef struct address
- {
- char municipality[15];
- char province[15];
- char city[10];
- }ADDR;
- typedef struct student
- {
- char name[30];
- ADDR STaddress;
- int Age;
- char Gender; //M or F only
- char course[10];
- int yrLevel;
- }STUDENT;
- void gotoxy(int X, int Y)
- {
- COORD coord;
- coord.X = X;
- coord.Y = Y;
- SetConsoleCursorPosition(
- GetStdHandle(STD_OUTPUT_HANDLE),
- coord
- );
- }
- void strup(char *input)
- {
- int index=0;
- for (index; input[index] != '\0'; index++)
- input[index] = toupper(input[index]);
- }
- STUDENT getinfo()
- {
- STUDENT input;
- printf("\n\tPlease enter student information");
- fflush(stdin);
- printf("\n\n\tName: "); gets(input.name); strup(input.name);
- printf("\n\tAddress\n");
- printf("\n\t\tMunicipality: "); gets(input.STaddress.municipality); strup(input.STaddress.municipality);
- printf("\n\t\tProvince: "); gets(input.STaddress.province); strup(input.STaddress.province);
- printf("\n\t\tCity: "); gets(input.STaddress.city); strup(input.STaddress.city); fflush(stdin);
- printf("\n\t\tCourse: "); gets(input.course); strup(input.course);
- printf("\n\t\tYearLevel: "); scanf_s("%d",&input.yrLevel); fflush(stdin);
- printf("\n\t\tAge: "); scanf_s("%d", &input.Age); fflush(stdin);
- printf("\n\t\tGender(M/F): "); scanf_s("%c", &input.Gender, 1); input.Gender = toupper(input.Gender);
- getchar();
- getchar();
- return input;
- }
- void printAllStudent(STUDENT *S)
- //display student information NAME COURSE YRLEVEL
- {
- int index;
- printf("\tName\t\t\t\t\tCourse\\Year\n");
- for (index = 81; index; index--)printf("-");
- int x = 8, y = 3;
- for (index = 0; index<STUDENTTOTAL; index++)
- gotoxy(x, y);
- _cputs(S[index].name); x += 35;
- gotoxy(x, y);
- printf_s("%s-%d", S[index].course, S[index].yrLevel);
- y++;
- }
- void printAll(STUDENT input)
- {
- printf("\n\n\tName: "); puts(input.name);
- printf("\n\t\tGender(M/F): "); printf("%c", input.Gender);
- printf("\n\t\tAge: "); printf("%d", input.Age);
- printf("\n\t\tCourse: "); puts(input.course);
- printf("\t\tYearLevel: "); printf("%d", input.yrLevel);
- printf("\n\tAddress\n");
- printf("\n\t\tMunicipality: "); puts(input.STaddress.municipality);
- printf("\t\tProvince: "); puts(input.STaddress.province);
- printf("\t\tCity: "); puts(input.STaddress.city);
- }
- void main()
- {
- STUDENT input[2];
- input[0] = getinfo();
- system("cls");
- fflush(stdin);
- input[1] = getinfo();
- puts("Press any key to continue");
- _getch();
- printAll(input[0]);
- printAll(input[1]);
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement