Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. //FUNCTIONS
  6. void mainMenu();
  7. void readStudent();
  8. void delay();
  9. //STRUCTS
  10.  
  11. int main(int argc, char const *argv[])
  12. {
  13.  
  14. //readStudent();
  15.  
  16. delay(2000);
  17. mainMenu();
  18. return 0;
  19. }
  20. void mainMenu(){
  21. int opt;
  22. printf("******************************************\n");
  23. printf("Select from the options:\n");
  24. printf("******************************************\n");
  25. printf("¬[1] Print my enrollment certificate\n");
  26. printf("¬[2] Print my courses\n");
  27. printf("¬[3] Print my transcript\n");
  28. printf("¬[4] Print my GPA\n");
  29. printf("¬[5] Print my ranking among all students in the college\n");
  30. printf("¬[6] List of all available courses\n");
  31. printf("¬[7] List of all students\n");
  32. printf("¬[8] Logout\n");
  33. printf("¬[9] Exit\n");
  34. printf("******************************************\n");
  35. printf("Enter the number corresponding to each item to proceed:\n");
  36. scanf("%d",&opt);
  37. switch(opt){
  38. case 1:
  39. printf("Dear Sir/Madam,\n\n");
  40. printf("This is to certify that Mr. [Peter Brown] with student id [7813007] is a student at grade 1 at CICCC. He\n");
  41. 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");
  42. printf("If you have any questions, please do not hesitate to contact us.\n");
  43. break;
  44. case 2:
  45. printf("Hi Mr. [Peter Brown],\n");
  46. printf("You have taken the following courses:\n");
  47.  
  48. break;
  49. case 3:
  50. printf("Hi Mr. [Peter Brown],\n");
  51. printf("Here is your transcript:\n\n");
  52. break;
  53. case 4:
  54. printf("Hi Mr. [Peter Brown],\n");
  55. printf("Your GPA is:\n\n");
  56. break;
  57. case 5:
  58. printf("Hi Mr. [Peter Brown],\n");
  59. printf("Your GPA is:[] and therefore your rank is []\n\n");
  60. break;
  61. case 6:
  62.  
  63. break;
  64. case 7:
  65.  
  66. break;
  67. case 8:
  68.  
  69. break;
  70. case 9:
  71. exit(1);
  72. break;
  73. default:
  74. printf("Wrong Option, please try again!\n");
  75. }
  76.  
  77. }
  78.  
  79. void readStudent(){
  80. // char com[] = "User:”";
  81. char file_name[] = "/home/carlos/Desktop/Project/Accounts.txt";
  82. // strcat( domain , file_name);
  83.  
  84. FILE *fp;
  85. char s[100];
  86. char userdata[100][100];
  87. char s_user[] = "User:";
  88. char s_pass[] = "Pass:";
  89. char *p;
  90.  
  91. char str3[128] = "";
  92. char *p1, *p2;
  93. size_t len,len2;
  94.  
  95. fp = fopen( file_name, "r" );
  96. if( fp == NULL ){
  97. printf( "%sIt's not opend file!\n", file_name );
  98. exit(1);
  99. }
  100.  
  101. int i = 0;
  102. while( fgets( s, 100, fp ) != NULL ){
  103. p = strstr(s, s_user);
  104. if(p == NULL){
  105. }else{
  106. p1 = s;
  107. len = strlen(s_user);
  108. while((p2 = strstr(p1,s_user)) != NULL) { // 削除文字列がなくなるまでループ
  109. strncat(str3,p1,p2 - p1); // 削除文字列を除いて連結
  110. p1 = p2 + len; // ポインタの更新
  111. }
  112.  
  113. strncpy( userdata[i], p1+1, 7 ); //p1の先頭+3の位置から5文字をusenumにコピー
  114. userdata[i][7] = '\0'; //でも文字数指定って..だめなきがする
  115. i++;
  116. }
  117. }
  118.  
  119. fclose( fp );
  120.  
  121. for (int a = 0; a < 15; a++) {
  122. printf( "%d :%s \n", a, userdata[a] );
  123. }
  124. }
  125.  
  126. void delay(int x){
  127. int c = 1, d = 1;
  128.  
  129. for ( c = 1 ; c <= x ; c++ )
  130. for ( d = 1 ; d <= 200000 ; d++ )
  131. {}
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement