<< < 12 13 14 15 16 17   Sort: Date

What is the deal on sprintfs return value?
What's the deal on sprintf's return value? Is it an int or a char *? The Standard says that it returns an int (the number of characters written, just like printf and fprintf). Once upon a time, in some C libraries, sprintf returned the char * value of its first argument, pointing to the completed re...
2015-10-16, 958👍, 0💬

I wrote this routine which is supposed to open a fi
I wrote this routine which is supposed to open a file: myfopen(char *filename, FILE *fp) { fp = fopen(filename, "r"); } But when I call it like this: FILE *infp; myfopen("filename.dat", infp); the infp variable in the caller doesn't get set properly. Functions in C always receive copies of their arg...
2015-10-09, 945👍, 0💬

I want to read and write numbers between files and memory ...
I want to read and write numbers between files and memory in a byte-at-a-time way, not as formatted characters the way fprintf and fscanf do. How can I do this? What you're trying to do is usually called ``binary'' I/O. First, make sure that you are calling fopen with the "b" modifier ("rb", "wb", e...
2015-09-24, 914👍, 0💬

<< < 12 13 14 15 16 17   Sort: Date