Hi guys im trying to get a program to read a file and copy its contents to another file so far I seem to be having a problem.
The file is only writing one letter, "X" in this case
Im just wondering what my problem is here?
the file im testing it on is just a massive text document, so there dhould be more than one letter comming out
Eventually im going to use this program to tidy up a text document with float values, that sounds confusing as I type it, but its just a text file with numeric data on it but its very messed up as it looks something like thisCode:#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main ( int argc, char *argv[] ) { if ( argc != 2 ) { printf( "usage: %s filename", argv[0] ); } else { FILE *file = fopen( argv[1], "r" ); if ( file == 0 ) { printf( "Could not open file\n" ); } else { int x; while ( ( x = fgetc( file ) ) != EOF ) { FILE *outf; //if (isspace(x)&&isspace(x-1) //remove space //else outf = fopen("test.txt","w"); fprintf(outf,"%c"); fclose(outf); } } fclose( file ); } }
What I want to do is tidy it up so that there is only one space between each value and hopefully start a new line after every 10 numbers.Code:121.2 12.12 121.21 1.212 1.12 121 121 1 1.212 12.12 121.2 12 ect....



LinkBack URL
About LinkBacks


