fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. bool string_compare(char* p, char* q){
  5. for( ; *p != '\0' && *q != '\0' ; p++, q++ ){
  6. if( *p != *q ){
  7. return false;
  8. }
  9. }
  10.  
  11. if( *p == *q ){
  12. return true;
  13. }
  14. return false;
  15. }
  16.  
  17. #define LEN 256
  18.  
  19. int main(void){
  20. char str1[LEN];
  21. char str2[] = "DRAGONQUEST";
  22.  
  23. scanf("%s", str1);
  24.  
  25. if( string_compare(str1, str2) ){
  26. printf("同じ\n");
  27. }else{
  28. printf("違う\n");
  29. }
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 9424KB
stdin
DRAGONQUEST
stdout
同じ