From the above code, I'm trying to figure out what I can do so that the loop will stop printing the character after null, so that no rubbish will come out behind null character.Code:#include <stdio.h> main() { char linetext[12]; int i; printf("Enter a line of text:"); scanf("%[^\n]", &linetext); for(i=0;i<10;i++) printf("%c", linetext[i]); printf("\n"); }
I'm a newbie, I tried to solve it, but I'm out of idea.
If you don't want to show any example, do provide some hint (not the hard one), I'll try it, example do appreciate though.