i am new on file(c)
if i copy
fscanf(nom du file,"%d",&a);
from where i want copy th value of a
plz send for me a example use fscanf plzzzzzzzz realy i need help :cry: :cry:
let me give you an example, Now if you have a file opened in textmode, which has integer values stored in it, and you want to read these numbers through C-code, then you can use fscanf();.
Now let the file name is : NUM.txt
then the code given will read nos. from this file.
FILE *fp; //File pointer
int num; //num variable will collect integers from the file
if(fp==NULL) //if file failed to open
printf("\nFile not opened\nPress any key to exit");
while(ch!='e'||ch!='E') //while you not press 'E'
Nonstandard header, typically only Windows or DOS compilers will have it. But AFAIK Borland compilers are the only ones that have a fully featured conio.h. Using it is dicey at best because the functions from it that you use may or may not be on another compiler that has conio.h, much less those that do not.
Be explicit as C will refuse to accept this in the future:
int main ( void )
Nonstandard function, use at your own risk. But getchar works just as well. Of course the counter argument is that getchar doesn't return until a newline (or error) is encountered. But really, how much is it to ask a user to type return rather than any key?
Why are you returning 0 if the program is terminating on an error? 0 means success, so you would be better off including stdlib.h and returning EXIT_FAILURE.
This tells me you're compiling as C++. Declarations can only be placed at the beginning of a block in C89. C99 changed this, but because you're using conio.h I feel reasonably comfortable calling you on the error as I don't know of any compilers that conform to C99 and support conio.h.
&& would bemore appropriate than ||.
main returns an int, so return an int or suffer undefined behavior.