Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     char * name = calloc(1, sizeof(char)), c;
  6.     int strLen = 0;
  7.  
  8.     while(scanf("%c", &c) == 1 && c != '\n') {
  9.         name[++strLen] = c;
  10.         name = realloc(name, (strLen + 1) * sizeof(char));
  11.     }
  12.  
  13.     for(char * rear = &name[strLen]; *rear;  rear--) {
  14.         printf("%c", *rear);
  15.     }
  16.     puts("");
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement