fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void readCharLine(char **line_address) {
  5. int c;
  6. int index = 0;
  7. *line_address = malloc(35 * sizeof(char));
  8.  
  9. /*Consume white spaces*/
  10. while ((c = getchar()) == ' ')
  11. ;
  12.  
  13. ungetc(c, stdin);
  14.  
  15. /*read rest of line*/
  16. while((c = getchar()) != '\n' && index < 35 - 1) {
  17. (*line_address)[index++] = c;
  18. }
  19. (*line_address)[index] = '\0';
  20. }
  21.  
  22. typedef struct {
  23. char *input;
  24. struct Node *next;
  25. } Node;
  26.  
  27. int main(void){
  28. Node *node = malloc(sizeof(*node));
  29.  
  30. node->next = NULL;
  31.  
  32. readCharLine(&node->input);
  33.  
  34. printf("%s\n", node->input);
  35. free(node->input);
  36. free(node);
  37. return 0;
  38. }
Success #stdin #stdout 0s 2248KB
stdin
   123456789A123456789B123456789C123456789D
stdout
123456789A123456789B123456789C1234