fork(1) download
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int counter(char s[]){
  5. int i=0;
  6. while(s[i]!='\0')
  7. {
  8. i++;
  9. };
  10. return i;
  11. };
  12.  
  13. char* setPalindrome(char s[]){
  14. int i;
  15. int k=0;
  16. i=counter(s);
  17. char*tmp=(char*)malloc(sizeof(char)*i*2+1);
  18. for(k;k<i;k++){
  19. tmp[k]=s[k];
  20. };
  21. for(int j=0;j<i;j++){
  22. tmp[i+j]=s[i-j];
  23. };
  24. tmp[i*2]='\0';
  25. return tmp;
  26. };
  27.  
  28.  
  29. int main(){
  30. char s[100];
  31. char* t;
  32. scanf("%s",s);
  33. t=setPalindrome(s);
  34. printf("%s",t);
  35. free(t);
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 544KB
stdin
ghi
stdout
ghi