Code:
for (i=0; i < strlen(somestring)-1; i++)
Because of the -1, this loop will never loop over the '\n' and you won't have a chance to remove it. Get rid of the -1, and perhaps save the result of strlen() because ot's a somewhat expensive operation.
[edit] eg
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char somestring[100];
printf("Please enter a string\n");
fgets(somestring, 100, stdin);
//the following will rebuild the string to get rid of any new lines so we can compare
//it with "test".
int i; // C99-style declarations in the middle of a block
size_t len = strlen(somestring);
for (i=0; i < len/*-1*/; i++)
{
if (somestring[i] != '\n'){
somestring[i] = somestring[i];
}
}
printf("\n%d", strcmp(somestring, "test"));
return 0;
}
Declaring variables in the middle of a block is C99; you might want to declare them at the start of the block.
[/edit]