KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to compare two strings. One stored in a file, the other retrieved from the user (stdin). Here is a sample program: int main() { char targetName[50]; fgets(targetName,50,stdin); char aName[] = "bob"; printf("%d",strcmp(aName,targetName)); return 0; } In this program, strcmp returns a value of -1 when the input is "bob" . Why is this? I thought they should be equal. How can I get it so that they are?
Tags (comma-separated)
Save Edits
Cancel