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. int setPalindrome(char s[]){
  14. int i=0;
  15. int j=1;
  16. int k=0;
  17. char*tmp;
  18. counter(s);
  19. tmp=(char*)malloc(sizeof(char)*i*2);
  20. for(k;k<i;k++){
  21. tmp[k]=s[k];
  22. };
  23. for(i=i-1;i>=0;i--){
  24. tmp[j+k]=s[i];
  25. k++;
  26. };
  27. tmp[j+k]='\0';
  28. counter(s);
  29. for(int h=0;h<i;h++){
  30. printf("%c",tmp[i]);
  31. };
  32. return 0;
  33. };
  34.  
  35.  
  36. int main(){
  37. char s[100];
  38. scanf("%s",s);
  39. setPalindrome(s);
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 5332KB
stdin
ghi
stdout
Standard output is empty