Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C - freopen or freopen_s

Name: Anonymous 2014-02-08 16:01

These functions, declared inside stdio.h, both have one thing that I couldn't find the use of:


== FILE * freopen( "asd.txt", "r+", oneFILE*variable ); ==

Why does this shit return a (FILE *)?
- The oneFILE*variable gets its previously held file closed, all good.
- The oneFILE*variable gets loaded with the "asd.txt" with "r+" attribute, all good.

Then the function fucking returns the same pointer, again, the same thing that has been fucking stored inside the oneFILE*variable, why?


== errno_t freopen_s( ONEdummyFILE**variable, "asd.txt", "r+", oneFILE*variable ) ==

Same shit again, why am I giving a retarded, no-use, dummy FILE** variable?

What the fuck is this? Does it have another explanation?

Name: Anonymous 2014-02-09 1:56

>>5
A single byte (char) would be able to do it.
Using smaller types than int or char * for function return values is a silly optimization (you'll notice that none of the functions in the standard library do it). On most architectures, a whole register is used for the return value regardless of whether you're  returning a char, an int, or a char *.

I think I'll just use freopen then, and disregard the return value
...and then your program will die horribly if anything bad happens to the file after you open it the first time.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List