fork download
  1. /*
  2. *
  3. * ICPA 10
  4. * By: Nguyen Nguyen
  5. *
  6. *
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. //Allow people to describe classes
  12. struct registration{
  13. char courseNumber [100];
  14. char courseName [100];
  15. char credits[100];
  16. char teacherName [100];
  17. };
  18.  
  19.  
  20. int main(){
  21. struct registration panel [100];
  22. int counter = 0;
  23. char userInput;
  24. do{
  25. printf("Please enter your classes (course Number, course Name, credits, teacher name: \n");
  26. scanf("%s%s%s%s\n", panel[counter].courseNumber, panel[counter].courseName, panel[counter].credits, panel[counter].teacherName); // User enter the information
  27.  
  28. printf("Do you want to continue? \n"); //After the information is entered, Ask if user want to add more input.
  29. scanf("%c", &userInput);
  30. printf("\n USER INP = %cjhjhjjh", userInput);
  31. counter++;
  32. }while(userInput == 'Y');
  33.  
  34.  
  35. for(int index = 0; index < counter; ++index){
  36. printf("%s %s %s %s", panel[index].courseNumber, panel[index].courseName, panel[index].credits, panel[index].teacherName);
  37. }
  38. return (0);
  39. }
Success #stdin #stdout 0s 4364KB
stdin
a b c d
Y
d e f g
n
stdout
Please enter your classes (course Number, course Name, credits, teacher name: 
Do you want to continue? 

 USER INP = YjhjhjjhPlease enter your classes (course Number, course Name, credits, teacher name: 
Do you want to continue? 

 USER INP = njhjhjjha b c dd e f g