I was looking into scanf() - shifts the cursor to next line so got curious if fgets does the same but the output I am getting does not make sense to me . Please help me out in understanding it
Code -
main()
{
char name[30] , name2[20];
scanf("%s" , name) ;
printf("%s" , name) ;
fgets(name2 , 30 , stdin) ;
printf("%s" , name2) ;
return 0 ;
}
Output - enter image description here
In the first line I input premier it gives an output of premier in second line but its not asking me for input second time and please clarify if fgets() also moves cursor to second line
THANKS FOR HELPING OUT!!!