Here's a snippet of the code:

Code:
FILE *fp;
    fp = fopen(argv[2], "r"); // the input file
    while (!(feof(fp))) {
        char c;
        int i = 0;
        char string[101]; // max string length is 100. last spot reserved for '\0'
        string[100] = '\0';
        while ((c = fgetc(fp)) != ' ' && i < 100) {
            string[i] = c;
            i++;
        }
        printf("%s\n",string);
    }
    fclose(fp);
This is just an example of a bigger problem that I'm having, but I feel like if I understand why this is happening.

The contents of the "argv[2]" file are as follows:

Code:
this is an input file
The output I am getting overall by this is:

this
isis
anis
input
file
�������������������������������������������������� �������������������������������������������� �

...as opposed to what I"m looking for:

this
is
an
input
file

I'm confused as to why the string doesn't seem to be a new string (i.e., why the second time around the string is "is" followed by the remaining two characters of the last string which also happen to be "is" making "isis" all together). Why doesn't the same thing happen to the last two? Why isn't "file" printed as "filet"? Very confusing.

Overall I'm just trying to get my desired output. Any suggestions as to why I'm not? Why is the string being overridden as opposed to the program making a new string for each iteration?