E
ern
I'm writing to a file called "output.txt" It *should* contain floating
point numbers delimited by semi-colons. Instead, it contains Chinese
characters.
/* HERE IS MY CODE */
FILE *fileHandle;
const char * filePath = "C:\\output.txt";
const char delimiter[1] = {';'};
char power_string[25];
float power_number = 25.53;
if( (fileHandle = fopen( filePath, "w" )) == NULL ){
printf( "The file %s could not be opened\n",filePath );
exit(0);
}else{ printf( "The file %s was opened\n",filePath );}
_gcvt(power_number,4,power_string); //convert to
string...
fwrite( power_string,sizeof(char),25,fileHandle ); //write power to
file
fwrite( delimiter,sizeof(char),2,fileHandle );//write delimiter to
file
fclose(fileHandle);
I saw in the debugger that the _gcvt command was doing it's job well.
I think the problem is my usage of fwrite. I thought it was my
delimiter, but the problem persists when I omit that line. Help is
much appreciated.
point numbers delimited by semi-colons. Instead, it contains Chinese
characters.
/* HERE IS MY CODE */
FILE *fileHandle;
const char * filePath = "C:\\output.txt";
const char delimiter[1] = {';'};
char power_string[25];
float power_number = 25.53;
if( (fileHandle = fopen( filePath, "w" )) == NULL ){
printf( "The file %s could not be opened\n",filePath );
exit(0);
}else{ printf( "The file %s was opened\n",filePath );}
_gcvt(power_number,4,power_string); //convert to
string...
fwrite( power_string,sizeof(char),25,fileHandle ); //write power to
file
fwrite( delimiter,sizeof(char),2,fileHandle );//write delimiter to
file
fclose(fileHandle);
I saw in the debugger that the _gcvt command was doing it's job well.
I think the problem is my usage of fwrite. I thought it was my
delimiter, but the problem persists when I omit that line. Help is
much appreciated.