Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- //FUNCTIONS
- void mainMenu();
- void readStudent();
- void delay();
- //STRUCTS
- int main(int argc, char const *argv[])
- {
- //readStudent();
- delay(2000);
- mainMenu();
- return 0;
- }
- void mainMenu(){
- int opt;
- printf("******************************************\n");
- printf("Select from the options:\n");
- printf("******************************************\n");
- printf("¬[1] Print my enrollment certificate\n");
- printf("¬[2] Print my courses\n");
- printf("¬[3] Print my transcript\n");
- printf("¬[4] Print my GPA\n");
- printf("¬[5] Print my ranking among all students in the college\n");
- printf("¬[6] List of all available courses\n");
- printf("¬[7] List of all students\n");
- printf("¬[8] Logout\n");
- printf("¬[9] Exit\n");
- printf("******************************************\n");
- printf("Enter the number corresponding to each item to proceed:\n");
- scanf("%d",&opt);
- switch(opt){
- case 1:
- printf("Dear Sir/Madam,\n\n");
- printf("This is to certify that Mr. [Peter Brown] with student id [7813007] is a student at grade 1 at CICCC. He\n");
- printf("was admited to our college in 2011 and has taken [1] course(s). Currently he resides at [850 West Vancouver, Vancouver]\n\n\n");
- printf("If you have any questions, please do not hesitate to contact us.\n");
- break;
- case 2:
- printf("Hi Mr. [Peter Brown],\n");
- printf("You have taken the following courses:\n");
- break;
- case 3:
- printf("Hi Mr. [Peter Brown],\n");
- printf("Here is your transcript:\n\n");
- break;
- case 4:
- printf("Hi Mr. [Peter Brown],\n");
- printf("Your GPA is:\n\n");
- break;
- case 5:
- printf("Hi Mr. [Peter Brown],\n");
- printf("Your GPA is:[] and therefore your rank is []\n\n");
- break;
- case 6:
- break;
- case 7:
- break;
- case 8:
- break;
- case 9:
- exit(1);
- break;
- default:
- printf("Wrong Option, please try again!\n");
- }
- }
- void readStudent(){
- // char com[] = "User:”";
- char file_name[] = "/home/carlos/Desktop/Project/Accounts.txt";
- // strcat( domain , file_name);
- FILE *fp;
- char s[100];
- char userdata[100][100];
- char s_user[] = "User:";
- char s_pass[] = "Pass:";
- char *p;
- char str3[128] = "";
- char *p1, *p2;
- size_t len,len2;
- fp = fopen( file_name, "r" );
- if( fp == NULL ){
- printf( "%sIt's not opend file!\n", file_name );
- exit(1);
- }
- int i = 0;
- while( fgets( s, 100, fp ) != NULL ){
- p = strstr(s, s_user);
- if(p == NULL){
- }else{
- p1 = s;
- len = strlen(s_user);
- while((p2 = strstr(p1,s_user)) != NULL) { // 削除文字列がなくなるまでループ
- strncat(str3,p1,p2 - p1); // 削除文字列を除いて連結
- p1 = p2 + len; // ポインタの更新
- }
- strncpy( userdata[i], p1+1, 7 ); //p1の先頭+3の位置から5文字をusenumにコピー
- userdata[i][7] = '\0'; //でも文字数指定って..だめなきがする
- i++;
- }
- }
- fclose( fp );
- for (int a = 0; a < 15; a++) {
- printf( "%d :%s \n", a, userdata[a] );
- }
- }
- void delay(int x){
- int c = 1, d = 1;
- for ( c = 1 ; c <= x ; c++ )
- for ( d = 1 ; d <= 200000 ; d++ )
- {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement