I added this code on a program supposedly to create a textfile(there were errors when I added the bottom part of the program marked with //textfile)
//here is a fragment of the program
void next_macroblock(Macroblock *currMB)
{
VideoParameters *p_Vid = currMB->p_Vid;
InputParameters *p_Inp = currMB->p_Inp;
Slice *currSlice = currMB->p_Slice;
int slice_type = currSlice->slice_type;
BitCounter *mbBits = &currMB->bits;
(some codes deleted)
// Statistics
cur_stats->quant[slice_type] += currMB->qp;
++cur_stats->num_macroblocks[slice_type];
//textfile
FILE * pFile;
pFile = fopen ("mytable.txt","w");
fprintf (pFile, " \t %d \t | \n",mbBits->mb_total);
fclose (pFile);
}
errors:
**c:\jm 18.4\lencod\src\macroblock.c(223): error C2275: 'FILE' : illegal use of this type as an expression**
**c:\program files\microsoft visual studio 11.0\vc\include\stdio.h(66) : see declaration of 'FILE'**
c:\jm 18.4\lencod\src\macroblock.c(223): error C2065: 'pFile' : undeclared identifier
c:\jm 18.4\lencod\src\macroblock.c(224): error C2065: 'pFile' : undeclared identifier
c:\jm 18.4\lencod\src\macroblock.c(224): warning C4047: '=' : 'int' differs in levels of indirection from 'FILE *'
c:\jm 18.4\lencod\src\macroblock.c(225): error C2065: 'pFile' : undeclared identifier
c:\jm 18.4\lencod\src\macroblock.c(225): warning C4047: 'function' : 'FILE *' differs in levels of indirection from 'int'
c:\jm 18.4\lencod\src\macroblock.c(225): warning C4024: 'fprintf' : different types for formal and actual parameter 1
c:\jm 18.4\lencod\src\macroblock.c(226): error C2065: 'pFile' : undeclared identifier
c:\jm 18.4\lencod\src\macroblock.c(226): warning C4047: 'function' : 'FILE *' differs in levels of indirection from 'int'
c:\jm 18.4\lencod\src\macroblock.c(226): warning C4024: 'fclose' : different types for formal and actual parameter 1
HERE'S THE PROBLEM: I already placed #include (becaues FILE is defined in stdio.h) then saved it in Unicode format (Because the program told me to save it in unicode format, otherwise more errors will appear), by going to FILE->advance saving options->UTF 8 with signature. The error about "saving the file in Unicode Format still persisted until I deleted some of the comments /* */ which contains German characters.
still the same errors about FILE. what went wrong?
According to @macduff and @KeithThompson I should include { } on that part of the code which I did. The errors were gone but no textfile was created (what I want to do is create a textfile which prints the values of the variables in the code.)
NEW QUESTION: If Visual Studio 2012 follows the C89/C90 standard and I can't declare variables in the middle of a function or a block, what is the best way to create a textfile in order to print the changing values of my variable mbBit->mb_total? (should I put { } on the codes to create a text file, make a new function or declare my paramaters in a header file - if yes, what parameters must I declare and how do I declare them?)
prile
undefined?fprintf(pfile, "%d", number->var_inp
? SSCCE, please. – milleniumbugFILE
. – macduff