K
KevinD
assumption: I am new to C and old to COBOL
I have been reading a lot (self teaching) but something is not sinking
in with respect to reading a simple file - one record at a time.
Using C, I am trying to read a flatfile. In COBOL, my simple file
layout and READ statement would look like below.
Question: what is the standard, simple coding convention for reading
in a flatfile - one record at a time?? SCANF does not work because of
spaces; I tried FGETS and STRUCT to emulate my COBOL perspective but
that does not work (though I may have coding this wrong). C likes to
deliver data in streams but FGETS is akin to reading a single record.
I know I am missing something that is very simple but the examples
that I have come across avoid this simple scenario. Please explain -
an example would be great.
thanks
kevin
.......
01 employee-record.
03 emp-id pic 9(5).
03 emp-dept pic x(5).
03 emp-name.
05 emp-name-last pic x(20).
05 emp-name-first pic x(20).
03 emp-hire-date.
05 emp-hire-date-mm pic 9(2).
05 emp-hire-date-dd pic 9(2).
05 emp-hire-date-yy pic 9(4).
read employee-flatfile into employee-record.
I have been reading a lot (self teaching) but something is not sinking
in with respect to reading a simple file - one record at a time.
Using C, I am trying to read a flatfile. In COBOL, my simple file
layout and READ statement would look like below.
Question: what is the standard, simple coding convention for reading
in a flatfile - one record at a time?? SCANF does not work because of
spaces; I tried FGETS and STRUCT to emulate my COBOL perspective but
that does not work (though I may have coding this wrong). C likes to
deliver data in streams but FGETS is akin to reading a single record.
I know I am missing something that is very simple but the examples
that I have come across avoid this simple scenario. Please explain -
an example would be great.
thanks
kevin
.......
01 employee-record.
03 emp-id pic 9(5).
03 emp-dept pic x(5).
03 emp-name.
05 emp-name-last pic x(20).
05 emp-name-first pic x(20).
03 emp-hire-date.
05 emp-hire-date-mm pic 9(2).
05 emp-hire-date-dd pic 9(2).
05 emp-hire-date-yy pic 9(4).
read employee-flatfile into employee-record.