-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi,
I got the following code:
char buffer[2047];
int charsRead;
do {
if(fscanf(file, "%2047[^\n]%n%*c", buffer, &charsRead) == 1) {
// Do something
}
} while (charsRead == 2047);
I wanted to convert this code to use dynamically allocated variables so that when calling this…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I've got some analysis code (myprog) that sucks in data using the following:
if(5 == fscanf(in, "%s%lf%f%f%f", tag, & sec, & tgt, & s1, & s2))
which works just fine. But in the situation where I've got data files that are separated by commas, I'm currently doing something like:
…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I've got some code executing in a while(fscanf != EOF) loop.
However, even when fscanf has finished executing, I need to keep running that code until some conditions are met.
I mean I guess I could copy/paste the code to outside the while(fscanf) loop, and only use global variables, but that seems…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
What is the best option if I want to "upgrade" old C-code to newer C++ when reading a file with a semicolon delimiter:
/* reading in from file C-like: */
fscanf(tFile, "%d", &mypost.nr); /*delimiter ; */
fscanf(tFile, " ;%[^;];", mypost.aftername);/* delimiter ; */
fscanf(tFile, " %[^;]", mypost…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
What is the best option if I want to "upgrade" old C-code to newer C++ when reading a file with a semicolon delimiter:
/* reading in from file C-like: */
fscanf(tFile, "%d", &mypost.nr); /*delimiter ; */
fscanf(tFile, " ;%[^;];", mypost.aftername);/* delimiter ; */
fscanf(tFile, " %[^;]", mypost…
>>> More