I want to read a line and put each word of this line in a linked list but i must use getchar.My problem is on how to read a line with getchar.(forget linked lists)
i make this
The problem the printf str doesn't print anything
i make this
Code:
#include <stdio.h> #define len 64 int main(void){ char str[len]; int i; do{ i=0; str[i]=getchar(); i++; }while (str[i-1]!= '\n' && i<len); str[i-1]='\0'; printf("%s", str); return 0; }
Comment