fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. char command[1000];
  9. char firstName[1000];
  10. char lastName[1000];
  11. char month[1000];
  12. char day[1000];
  13.  
  14. while( strcmp("quit", &command[0]) != 0 ){
  15. fflush(stdin);
  16.  
  17. printf("Please enter next command: ");
  18. scanf("%s", command); // <--- This is tested and working
  19.  
  20. if(strcmp(&command[0], "quit") == 0){
  21. break;
  22. }
  23.  
  24. else if(strcmp(&command[0], "empty") == 0){
  25. // empty();
  26. }
  27. else if(strcmp(&command[0], "append") == 0){
  28. printf("--------->1");
  29.  
  30. scanf("%s %s %s %s", firstName, lastName, month, day); //<--- This line :(
  31.  
  32. printf("--------->2"); // <---- This never prints
  33. char fullName[2001];
  34. char birthday[2001];
  35.  
  36. strcpy(fullName,firstName);
  37. strcat(fullName,lastName);
  38.  
  39. printf("%s", fullName);
  40. }
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0s 3344KB
stdin
append greg r jan 02 quit
stdout
Please enter next command: --------->1--------->2gregrPlease enter next command: