Page 1 of 1
Problem: my code FILE<--RESOLVED->Tnk MAk
Posted:
Thu Apr 09, 2009 10:56 pm
by equinox
IN this code there is a error,,, but i dont found it.
FILE*file;//*** LOAD CHAR E PRINT
file = fopen("TextNote.txt", "r");
fread(&N, sizeof(N), 2, file);
fclose(file);
strcpy(A1.text, N[0][0]);// funzia
//sprintf(getclone2(A1.name, 0)->text ,"NAME: %s", N[0]);
some ideas on how to solve it,please?
Tnk1000.
Re: Problem: my code FILE write string array
Posted:
Fri Apr 10, 2009 3:19 pm
by makslane
Can you explaint what you want and the format of the TextNote.txt file?
The TextNote.txt isn't a text file!
Re: Problem: my code FILE
Posted:
Sat Apr 11, 2009 12:05 pm
by equinox
FILE *f;
int PX = 10;
int F[3] = {1,2,3}
memset(PX,0,sizeof(PX));
memset(F,0,sizeof(F));
if((f = fopen("save.txt", "wb"))){
fwrite(PX, 1, sizeof(PX),f);
fwrite(F, 1, sizeof(F),f);
fclose(f);
-----------------------------
if((f = fopen("save.txt", "rb"))){
fread(PX, 1, sizeof(PX),f);
read(F, 1, sizeof(F),f);
fclose(f);
-------------------
sprintf("PX %d", PX);
sprintf("F[0] %d", F[0]);
but not print .
Re: Problem: my code FILE
Posted:
Sat Apr 11, 2009 12:23 pm
by makslane
Try reproduce this code on your ged file.
There are some things wrong in your code, like useing "w" intead "wb" or "r" instead "rb".
Re: Problem: my code FILE
Posted:
Sun Apr 12, 2009 8:10 am
by equinox
Yes !!!
There are some things wrong in your code, like useing "w" intead "wb" or "r" instead "rb".
Tnk1000 Mak, the solution was "r" and "w" != "wb" "rb"