Enter included in fgets

I'm trying to input a user response with fgets but fgets is also including the enter. Is there anyway to get rid of it or not include it in the first place? Here's my code:

1
2
3
4
5
6
7
8
  int main(int argc, const char * argv[]) {
    //Gets name
    printf("Please enter a name for your charachter:");
    fflush(stdout);
    fgets(response, 50, stdin);
    
    a[0].personName = response;
    //a is a class 

I declare response as:
 
char response[50];
1
2
char* p = strchr( response, '\n' );
if (p) *p = '\0';
Topic archived. No new replies allowed.