<< < 169 170 171 172 173 174   Sort: Date

I am trying to update a file in place ...
I'm trying to update a file in place, by using fopen mode "r+", reading a certain string, and writing back a modified string, but it's not working. Be sure to call fseek before you write, both to seek back to the beginning of the string you're trying to overwrite, and because an fseek or fflush is a...
2015-10-07, 1149👍, 0💬

How can I recover the file name given an open stream?
How can I recover the file name given an open stream? This problem is, in general, insoluble. Under Unix, for instance, a scan of the entire disk (perhaps involving special permissions) would theoretically be required, and would fail if the descriptor were connected to a pipe or referred to a delete...
2015-10-05, 1141👍, 0💬

I cant even get a simple fopen call to work
I can't even get a simple fopen call to work! What's wrong with this call? FILE *fp = fopen(filename, 'r'); fopen's mode argument must be a string, like "r", not a character like 'r'.
2015-10-09, 1140👍, 0💬

I need code to parse and evaluate expressions.
I need code to parse and evaluate expressions. Two available packages are ``defunc,'' posted to comp.sources.misc in December, 1993 (V41 i32,33), to alt.sources in January, 1994, and available from sunsite.unc.edu in pub/packages/development/libra ries/defunc-1.3.tar.Z,and ``parse,'' at lamont.ldgo....
2015-05-01, 1136👍, 0💬

What is the difference between text and binary I/O?
What is the difference between text and binary I/O? In text mode, a file is assumed to consist of lines of printable characters (perhaps including tabs). The routines in the stdio library (getc, putc, and all the rest) translate between the underlying system's end-of-line representation and the sing...
2015-09-21, 1135👍, 0💬

How can I delete a file?
How can I delete a file? The Standard C Library function is remove. (This is therefore one of the few questions in this section for which the answer is not ``It's system-dependent.'') On older, pre-ANSI Unix systems, remove may not exist, in which case you can try unlink.
2015-04-10, 1134👍, 0💬

How can I read data from data files with particular formats?
How can I read data from data files with particular formats? How can I read ten floats without having to use a jawbreaker scanf format like "%f %f %f %f %f %f %f %f %f %f"? How can I read an arbitrary number of fields from a line into an array? In general, there are three main ways of parsing data l...
2015-10-26, 1133👍, 0💬

I know that the library function localtime will convert ...
I know that the library function localtime will convert a time_t into a broken-down struct tm, and that ctime will convert a time_t to a printable string. How can I perform the inverse operations of converting a struct tm or a string into a time_t? ANSI C specifies a library function, mktime, which ...
2015-08-05, 1127👍, 0💬

I am getting strange syntax errors on the very first declaration in a file, but it looks fine.
I am getting strange syntax errors on the very first declaration in a file, but it looks fine. Perhaps there's a missing semicolon at the end of the last declaration in the last header file you're #including.
2016-02-12, 1095👍, 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, 1089👍, 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, 1028👍, 0💬

<< < 169 170 171 172 173 174   Sort: Date