Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help reading from a data file 1

Status
Not open for further replies.

Deckster

IS-IT--Management
Aug 21, 2003
9
US
Trying to read data into a structure...afraid I might have it ALL wrong. Here's the code snippets:


Code:
typedef struct
{
char LineNumber[MAX];
char StructureName[MAX];
double Span;
} HiVLine[MAX];

...

int num = 0;

while(fscanf(cfPtr, "%s%s%d", HiVLine[num].LineNumber, HiVLine[num].StructureName, HiVLine[num].Span) != NULL)
   {
   num++;
   }
 
Try
Code:
while ( num < MAX &&
        fscanf(cfPtr, "%s%s%d", HiVLine[num].LineNumber, HiVLine[num].StructureName, &HiVLine[num].Span) == 3 )

--
 
Salem - This is what I get on compile:

: 1506-046 (S) Syntax error.

any ideas?
 
Without knowing what your operating system and compiler is, and a paste of the code which you tried, I've no idea.

Usually means you've missed a quote, comma, bracket, parenthesis.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top