fork download
  1. #include <stdio.h>
  2.  
  3. int main(){
  4. char name[30],reponse[3],response[3]="yes",temp;
  5. int j,i,t=0,k;
  6. printf("would you share with us your name ? \n");
  7. scanf("%s",name);
  8. printf("so your name is %s\n",name);
  9. for(i=0;i<=30;i++){
  10. if(name[i]!='\0') t++ ;
  11. else break;
  12. }
  13. printf("the number of letters in your name is %d\n",t);
  14. printf("do you want your name to be scrumbled ?\n");
  15. scanf("%3s",reponse);// I think the problem is here
  16. for(j=0;j < 3;j++){
  17. if(response[j]!=reponse[j]) break;
  18. }
  19. if(j==3){
  20. k = t/2;
  21. for(i=0; i<k;i++){
  22. temp=name[i];
  23. name[i]=name[t-i-1];
  24. name[t-i-1]=temp;
  25. }
  26. printf("your new name is %s hahaha ",name);
  27. }
  28. else printf("OK");
  29. return 0;
  30. }
Success #stdin #stdout 0s 9432KB
stdin
Bob
yes
stdout
would you share with us your name ? 
so your name is Bob
the number of letters in your name is 3
do you want your name to be scrumbled ?
your new name is boB hahaha