C++/file in c
i want to learn about file code,i wrote the fallowing code it doesn't have error but doesn't work
could you plz tell tell me what's the matter with it?
and my second question is that when we write:
we should create the "text" file in c directory?
and if yes.what kind of file we should make in c directory?(notepad,word...)
> it doesn't have error but doesn't work
that it compiles is no guarantee that it will not fail at run time.
on successful completion, fopen() return a FILE pointer. on failure, NULL is returned and the global variable errno is set to indicate the error.
> we should create the "text" file in c directory?
no file would be created. if the second argument (the 'mode' of opening) is "r" or "r+", the file is being opened for reading and therefore must be an already existing file.
> what kind of file we should make in c directory?(notepad,word...)
as far as C or C++ is concerned, a file is just a sequence of bytes. it does not distinguish between different 'kinds' of files other than text files (escape sequences like '\n' may need translation) and binary files (no such translation is required).