fgets() doesn't function as expected [duplicate]
问题 This question already has answers here : fgets doesn't work after scanf (7 answers) scanf() leaves the new line char in the buffer (4 answers) Closed 2 years ago . This is my code int main(){ int N,i,radius,diameter,count =0; char str[20]; char color[N][20]; printf("Get the num : "); scanf("%d",&N); printf("Enter the mesage\n"); for(i=0;i<N;i++){ fgets(color[i],20,stdin); } for(i=0;i<N;i++){ printf("%s",color[i]); } return 0; } Given inputs are: N = 3 red 50, 50 green, blue 50 Here the