I used to use gets but then I heard that it got removed from c11 and that its overall very dangerous. So I did some searching and found out that you can use fgets() to do the same thing.
The problems is that when I do use fgets() it seems to also copy the end of the line aswell, which ends up making an extra unwanted line.
To show you what I mean:
//if I have
char key[30];
fgets(key, sizeof(key), stdin);
//now if ender for instance: Doggo and do:
printf("The key is:%s|hozaah!\n", key);
//I expect it to print:
The key is:Doggo|hozaah!
//Instead it prints:
The key is:Doggo
|hozaah!
Is there a way to get around this? Or is there another function I can use instead?