fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void){
  5. char *UserInput = calloc(1, sizeof(char));
  6. int i = 1, ii = 0;
  7. printf("Enter a message! \n");
  8. while(scanf("%c", UserInput + ii) == 1 && UserInput[ii] != '\n'){
  9. ii = i++;
  10. UserInput=realloc(UserInput, i * sizeof(char));//Need check return value of realloc
  11. }
  12. for(i=0;i<=ii;i++){
  13. printf("%c",*(UserInput+i));
  14. }
  15. free(UserInput);
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 9424KB
stdin
it will show it back to me, but if I typed something with more characters it doesn't.
stdout
Enter a message! 
it will show it back to me, but if I typed something with more characters it doesn't.