fgets
reads until it sees a newline then returns, so when you type bob, in the console, targetName
contains "bob\n" which doesn't match "bob".
From the fgets documenation: (bolding added)
Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or a the End-of-File is reached, whichever comes first.
A newline character makes fgets stop reading, but it is considered a valid character and therefore it is included in the string copied to str.
A null character is automatically appended in str after the characters read to signal the end of the C string.
You need to remove the newline from the end of targetName before you compare.
int cch = strlen(targetName);
if (cch > 1 && targetName[cch-1] == '\n')
targetName[cch-1] = '\0';
or add the newline to your test string.
char targetName[50];
fgets(targetName,50,stdin);
char aName[] = "bob\n";
printf("%d",strcmp(aName,targetName));