Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is FILE not recognized even after putting #include <stdio.h>? (c language)
    text
    copied!<p>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)</p> <pre><code>//here is a fragment of the program void next_macroblock(Macroblock *currMB) { VideoParameters *p_Vid = currMB-&gt;p_Vid; InputParameters *p_Inp = currMB-&gt;p_Inp; Slice *currSlice = currMB-&gt;p_Slice; int slice_type = currSlice-&gt;slice_type; BitCounter *mbBits = &amp;currMB-&gt;bits; (some codes deleted) // Statistics cur_stats-&gt;quant[slice_type] += currMB-&gt;qp; ++cur_stats-&gt;num_macroblocks[slice_type]; //textfile FILE * pFile; pFile = fopen ("mytable.txt","w"); fprintf (pFile, " \t %d \t | \n",mbBits-&gt;mb_total); fclose (pFile); } </code></pre> <p>errors:</p> <pre><code>**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 </code></pre> <p><strong>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.</strong></p> <p>still the same errors about FILE. what went wrong?</p> <p><em><strong>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.)</em></strong></p> <p><strong>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?)</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload