Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

fscanf question.

Old 01-29-01, 03:15 PM
  #1  
DVD Talk Limited Edition
Thread Starter
 
cartman's Avatar
 
Join Date: Oct 1999
Location: SP, Colorado
Posts: 5,344
OK. I thought I knew how this function worked, but apparantly I don't. What parameters does it take? I thought it took this: fscanf(filename, 80, wholestring), where filename is the file to be read from defined as char filename[30], 80 is the max number of characters to read from the line, and wholestring is where to put the read line defined as char wholestring[81], but I am getting a "cannot convert parameter 1 from 'char [30]' to 'struct _iobuf *'" error. Help!
cartman is offline  
Old 01-29-01, 04:59 PM
  #2  
Mod Emeritus
 
Join Date: Feb 1999
Location: Central Vermont
Posts: 3,883
http://www.gator.net/~garyg/C/MAN/fscanf.htm

------------------
DVD-ROM & Computer Forum Moderator - [email protected]
DVD-ROM FAQ - Jason's Digital Domain - AIM: northrupjason
Jason Northrup is offline  
Old 01-29-01, 05:12 PM
  #3  
DVD Talk Limited Edition
Thread Starter
 
cartman's Avatar
 
Join Date: Oct 1999
Location: SP, Colorado
Posts: 5,344
quote:
Originally posted by Jason Northrup:
http://www.gator.net/~garyg/C/MAN/fscanf.htm




Yeah, that's about what my C book says...

According to that, what I am doing should work, but I must not be understanding something, because I still get the error.
cartman is offline  
Old 01-29-01, 05:20 PM
  #4  
DVD Talk Ultimate Edition
 
Join Date: Aug 2000
Location: Canada
Posts: 4,538
quote:
Originally posted by cartman:
OK. I thought I knew how this function worked, but apparantly I don't. What parameters does it take? I thought it took this: fscanf(filename, 80, wholestring), where filename is the file to be read from defined as char filename[30], 80 is the max number of characters to read from the line, and wholestring is where to put the read line defined as char wholestring[81], but I am getting a "cannot convert parameter 1 from 'char [30]' to 'struct _iobuf *'" error. Help!



I did a little bit of C back in the days... and just seeing that bit of code isn't enough to help. That error seems to mean you're trying to convert a table to a pointer to a struct declaration... Since I really suck at that, I can't help without seeing move of the code.

Also, why are you trying to read a filename as a table??
Feneant is offline  
Old 01-29-01, 05:31 PM
  #5  
DVD Talk Limited Edition
Thread Starter
 
cartman's Avatar
 
Join Date: Oct 1999
Location: SP, Colorado
Posts: 5,344
quote:
Originally posted by Feneant:
I did a little bit of C back in the days... and just seeing that bit of code isn't enough to help. That error seems to mean you're trying to convert a table to a pointer to a struct declaration... Since I really suck at that, I can't help without seeing move of the code.

Also, why are you trying to read a filename as a table??



Hmmmmm... is that what I'm doing wrong? I've got to read in one line of a file at a time, and thought using it that way would mean:

fscanf(filename, 80, wholestring);

reads first line (80 characters max) of filename and puts it in wholestring.

I take it I am incorrect. What should I be doing then?


[This message has been edited by cartman (edited January 29, 2001).]
cartman is offline  
Old 01-29-01, 08:25 PM
  #6  
Mod Emeritus
 
Join Date: Feb 1999
Location: Central Vermont
Posts: 3,883
quote:
Originally posted by cartman:
fscanf(filename, 80, wholestring);





I'm not sure what you mean by the filename variable. If it is a character string with the name/path of the file, that would be incorrect. What you need is a file pointer (FILE*). You may also want to put a check to make sure the file is opened (if you haven't done so already).


------------------
DVD-ROM & Computer Forum Moderator - [email protected]
DVD-ROM FAQ - Jason's Digital Domain - AIM: northrupjason
Jason Northrup is offline  
Old 01-29-01, 08:58 PM
  #7  
DVD Talk Limited Edition
Thread Starter
 
cartman's Avatar
 
Join Date: Oct 1999
Location: SP, Colorado
Posts: 5,344
quote:
Originally posted by Jason Northrup:

I'm not sure what you mean by the filename variable. If it is a character string with the name/path of the file, that would be incorrect. What you need is a file pointer (FILE*). You may also want to put a check to make sure the file is opened (if you haven't done so already).





AH HA! Goldermuddafriggingpointers.... Danke!
cartman is offline  
Old 01-29-01, 09:44 PM
  #8  
Mod Emeritus
 
Join Date: Feb 1999
Location: Central Vermont
Posts: 3,883
quote:
Originally posted by cartman:
AH HA! Goldermuddafriggingpointers.... Danke!



HEY! Don't diss the pointers. Pointers are cool. (Of corse references are way better, but that's C++.)

------------------
DVD-ROM & Computer Forum Moderator - [email protected]
DVD-ROM FAQ - Jason's Digital Domain - AIM: northrupjason
Jason Northrup is offline  
Old 01-30-01, 09:36 AM
  #9  
Senior Member
 
Join Date: Jul 1999
Posts: 464
As my proff in college once said, in C if you get an error that doesn't make sense, make the variable a pointer and that usually fixes it!!

Not the greatest programing prof, but still accurate.

Some of the functions in C just plain don't make sense, and the MAN pages are written by a bunch of geeks who never see the sun, or english as a native language....makes it hard to figure out what they mean sometimes.
Aaron Campagnone is offline  

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive Advertising Cookie Policy Privacy Statement Terms of Service

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.