Advertisement
BladeMechanics

Strcmp sample

Aug 20th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5.  
  6. void main()
  7. {
  8. char input[255], input2[255], choice;
  9. do {
  10. system("CLS");
  11. printf("Please enter a string: \t\t");
  12. fgets(input, 254, stdin);
  13. printf("\nPlease enter another string: \t");
  14. fgets(input2, 254, stdin);
  15. if (strcmp(input, input2) == 0)
  16. printf("The strings: \n%s\n%s\n are identical.", input, input2);
  17. else
  18. printf("The strings: \n%s\n%s\n are not identical.", input, input2);
  19. printf("\nDo you want to continue? [Y]es or Enter or just press any other key to exit.\n");
  20. choice = _getche();
  21. } while (choice == 'Y' || choice == 'y' || choice== '\r');
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement