fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void setPalindrome(char s[]);
  6.  
  7. int main(void) {
  8. char *p;
  9. char s[100];
  10. scanf("%s", s);
  11.  
  12. int d = 0;
  13. while (s[d] != '\0') {
  14. d++; }
  15.  
  16. p = (char*)malloc(sizeof(char)*(d*2+1));
  17. printf("%s", s);
  18. setPalindrome(s);
  19. free(p);
  20. return 0;
  21. }
  22. void setPalindrome(char s[]) {
  23. int d=0;
  24. for(int i=0; s[i]!='\0'; i++) {
  25. d++;
  26. }
  27. int j;
  28. for(j=d-1; j>=0; j--) {
  29. printf("%c", s[j]);
  30. }}
Success #stdin #stdout 0s 5296KB
stdin
aghgh
stdout
aghghhghga