I added the code above. I am not familiar with perror but I assume that if that condition was true it would have reported that error during compiling. The program compiled fine and when I added fprintf (output, "Outside") and another one that should print "inside" in the loop just to see if I could write to the file at all. This did not print to the file either. This leads me to believe I have some error in opening the file or in my syntax in writing to the file. Thanks again for the help, it is very appreciated.
The code again, for reference:
Code:
#include <stdio.h>
#define max 5000
int main (void)
{
char data [max];
int j = 0, i=0;
FILE* input;
FILE* output;
input = fopen ("input_40x10x300_nohead.cor", "r"); //open the input file
output = fopen ("input_new_40x10x300.cor", "w");
if ( input == NULL ) {
perror( "Can't open input file" );
exit( 1 );
}
fprintf (output, "outside");
for(j=1; j<max && fscanf(input, "%c", &data[j]) != EOF; j++)
{
if (data[j] == ' ')
{
i++;
}
if(i < 4 || i >= 7)
{
fprintf (output, "%c", data[j]);
fprintf (output, "inside");
}
if (data[j] == '\n')
{
j=0;
i=0;
}
}
fclose (input);
fclose(output);
return 0;
*edit: code was only half there.