Usage of fgets function in C
One of my assignments in to write my own UNIX Shell. To receive input from the user, I am using fgets to capture the input as a string but I'm not really sure how it works. When I run: char command[50]; fgets(command, sizeof(command), stdin); printf("Your Command: %s", &command); int length = strlen(command); printf("Length of String: %d\n", length); Lets say my the input was "exit". strlen says that the string is 5 characters long, instead of four. I want to do this: if( (strcmp(command, "exit")) == 0 ){ doSomething(); } but command is never equaling the string that I want it to; its like it