fork(1) 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.  
  18. printf("%s", s);
  19. setPalindrome(s);
  20. free(p);
  21. return 0;
  22. }
  23. void setPalindrome(char s[]) {
  24. int d=0;
  25. for(int i=0; s[i]!='\0'; i++) {
  26. d++;
  27. }
  28. int j;
  29. for(j=d-1; j>=0; j--) {
  30. printf("%c", s[j]); }}
Success #stdin #stdout 0s 5280KB
stdin
aghghjjkms
stdout
aghghjjkmssmkjjhghga