03-14-2002
fscanf()
thanks to everyone for your earlier replies, but i have yet another problem with file i/o. i'm trying to read multiple lines with the same file, and have been using the following code to take in the first two lines from a file...
fscanf(fileptr, "%d %d %d %d %d %d\n", &n1, &n2, &n3, &n4, &n5, &n6);
...some code in between...
fscanf(fileptr, "%d %d %d %d %d %d\n", &n1, &n2, &n3, &n4, &n5, &n6);
...what ends up happening is that it reads the first line in the file twice without continuing down to the second line. is there some sort of flag or identifier i need to set in order to ensure that the fileptr doesn't reset to the beginning? might i be accidentally resetting the fileptr (though i only use it in fopen, fclose, fscanf) inadvertently? any help would be greatly appreciated, thanks again...
7 More Discussions You Might Find Interesting
1. Programming
I keep trying to use fscanf() and for some reason I can't get the syntax down and always get seg faults. I'm on a SunOS 5.5.1, and my current code looks like this:
int n1, n2, n3, n4, n5, n6;
/* open config file */
if (fileptr = fopen(filename,"r") == NULL) {
printf("couldn't open... (3 Replies)
Discussion started by: j_t_kim
3 Replies
2. Programming
Hi,
Can any one tell me what "%hx" as control parameter mean in fscanf.
Thanks,
abey (4 Replies)
Discussion started by: abey
4 Replies
3. Programming
I use fopen, fscanf, fclose to read a file. It can work well. since many files should be read, a function is created with the same code. But in the function, fscanf can not work well.
for example, the first line of the the file is: > filename
but the fscanf will give: 207/23/eee/34
it appears... (2 Replies)
Discussion started by: cdbug
2 Replies
4. Programming
hey guys, I'm working on a term project for a c/unix class. The basis of the program is that it will calculate the weight/balance of a plane. I'm hoping to have an input file as such:
"
Pilot weight:
Passenger weight:
baggage wieght:
etc
"
and the idea is that I'm trying to use... (2 Replies)
Discussion started by: jlangholzj
2 Replies
5. Programming
Hi
I have a file like that:
1 2 3 4 5 6 7 8
and I want print on stdout:
1 3 8
in other words i want choose what print out.
I was thinking to use fscanf as:
fscanf(file_in,"%d %d %d",&a, &b,&c);
but in this way i get:
1 2 3
Is there a solution using fscanf to obtain my... (2 Replies)
Discussion started by: Dedalus
2 Replies
6. UNIX for Dummies Questions & Answers
hi there...
i have a question regarding the fscanf function...
let's say i have a data:
1 2 3 4 5 6
7 8 9 1 2 3
4 5 6 7 8 9
1 2 3 4 5 6
how do i read only the first COLUMN, or the second COLUMN or the third COLUMN or etc....??????
thanks (1 Reply)
Discussion started by: theunknown
1 Replies
7. Programming
Hi,
I have a file with contents like "abcd 1234" .What i need is get that integer and replace that with 0. So i used fscanf(fp,"%s %d", str, &num); This is having some problem.
There can be multiple space/tab between string and number. How to replace that number with 0 in same file? (4 Replies)
Discussion started by: explore
4 Replies
LEARN ABOUT DEBIAN
file2sdr
FILE2SDR(1) ICI executables FILE2SDR(1)
NAME
file2sdr - SDR data ingestion test program
SYNOPSIS
file2sdr configFlags fileName
DESCRIPTION
file2sdr stress-tests SDR data ingestion by repeatedly writing all text lines of the file named fileName to one of a series of non-volatile
linked lists created in a test SDR data store named "testsdrconfigFlags". By incorporating the data store configuration into the name
(e.g., "testsdr14") we make it relatively easy to perform comparative testing on SDR data stores that are identical aside from their
configuration settings.
The operation of file2sdr is cyclical: a new linked list is created each time the program finishes copying the file's text lines and starts
over again. If you use ^C to terminate file2sdr and then restart it, the program resumes operation at the point where it left off.
After writing each line to the current linked list, file2sdr gives a semaphore to indicate that the list is now non-empty. This is mainly
for the benefit of the complementary test program sdr2file(1).
At the end of each cycle file2sdr appends a final EOF line to the current linked list, containing the text "*** End of the file ***", and
prints a brief performance report:
Processing I<lineCount> lines per second.
EXIT STATUS
0 file2sdr has terminated.
FILES
No configuration files are needed.
ENVIRONMENT
No environment variables apply.
DIAGNOSTICS
Diagnostic messages produced by file2sdr are written to the ION log file ion.log.
Can't use sdr.
ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
Can't create semaphore.
ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
SDR transaction failed.
ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun.
Can't open input file
Operating system error. Check errtext, correct problem, and rerun.
Can't reopen input file
Operating system error. Check errtext, correct problem, and rerun.
Can't read from input file
Operating system error. Check errtext, correct problem, and rerun.
BUGS
Report bugs to <ion-bugs@korgano.eecs.ohiou.edu>
SEE ALSO
sdr2file(1), sdr(3)
perl v5.14.2 2012-05-25 FILE2SDR(1)