strip new line character from end from char*
<p>I have a <code>char* line</code> on which I used <code>while (fgets(line, line_size, fNames) != NULL)</code>. now the problem is I also get a new line character, which I want to strip.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

int main() {
    int i;
    char fileName[30];
    FILE *fNames, *fCurrent;
    char *line = NULL, command[100];
    char letters3[3];
    size_t len = 0;
    //size_t read;
    const size_t line_size = 300;
    line = malloc(line_size);
    if (access("fileNames.lst", F_OK) == -1)
        system("crunch 3 3 abcd -o fileNames.lst");
    else
        printf("fileNames.lst already exists.\n");
    fNames = fopen("./fileNames.lst","r");

    while (fgets(line, line_size, fNames) != NULL) {
        printf("Making File: %s.lst\n", line);
        strcpy(command, "crunch 8 8 -t ");
        strcpy(command, line);
        strcpy(command, strcat(command," -o"));
        puts(command);
        strcpy(line, strcat(line, ".lst"));
        fCurrent = fopen(line, "w");
        //system(command);
        fclose(fCurrent);
        //system("read -r -p \"Press space to continue...\" key");
    }
    return 0;
}
</code></pre>