// Pantea Aria // strings - remove_trailing_new_line #include #include void remove_new_line(char input2[]); int main(void) { //char input1[] = "Pantea"; char input2[10]; // fgets a new input2, enter "Pantea" if (fgets(input2, 10, stdin) == NULL) { //Pantea\n return 0; } // then strcmp with "Pantea" int result = strcmp(input2, "Pantea"); //Pantea, Pantea printf ("strcmp returned %d\n", result); // is there any issue? // the issue is the \n that I entered after Pantea // check if we have a \n at the end of input2 remove it remove_new_line(input2); printf ("after removing new line, strcmp returns %d\n", strcmp(input2, "Pantea")); return 0; } // remove_trailing_new_line void remove_new_line(char input2[]) { // check if the last character of input2 is \n // let's find the length of the string int len = strlen(input2); if ((input2[len - 1]) == '\n') { input2[len - 1] = '\0'; } }