I am an absolute beginner to programming and I am starting with the C language. I am currently using the Beginning Programming with C for Dummies book by Dan Gookin.
When doing an exercise with fgets() the following occurred.
This is my code
#include <stdio.h> int main() { char name[10]; printf("Who are you? "); fgets(name,10,stdin); printf("Glad to meet you, %s.\n",name); return(0); } The expected result should be a name with a full stop at the end and what is happening is that the full stop carries over to the next line like shown below.
I am using the code blocks IDE on Ubuntu

fgets?name[strcspn(name, "\n")] = '\0';.<string.h>to usestrcspn().