943,574 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1675
  • C++ RSS
Feb 7th, 2008
0

formated file reading problem

Expand Post »
As i knew the <stdarg.h> header should have the following function

int vfscanf(FILE *stream, const char *format, va_list ap);

but under Visual Studio 2005, after including the header and calling the function i get
'vfscanf': identifier not found

if the function is not declared, can u tell me some simmilar functions that do the same
thing and have the same parameters?

thx
Similar Threads
kux
Reputation Points: 66
Solved Threads: 11
Junior Poster
kux is offline Offline
119 posts
since Jan 2008
Feb 7th, 2008
0

Re: formated file reading problem

I don't think it is supported. A replacement might be fscanf() + some extra code, but it really depends on what you are doing with with vfscanf.
Reputation Points: 36
Solved Threads: 0
Light Poster
Passmark is offline Offline
32 posts
since Jan 2008
Feb 7th, 2008
0

Re: formated file reading problem

Click to Expand / Collapse  Quote originally posted by Passmark ...
I don't think it is supported. A replacement might be fscanf() + some extra code, but it really depends on what you are doing with with vfscanf.
hmmm, what i am doing is that i want to wrap my formated file read in a File class that i design myself so that it throws exceptions for every problem that might occur.
what i want to is to have a Scan method in my File class that looks like

void File:can ( const char * Format, ... )
{
va_list objArgs;
va_start( objArgs, pcFormat );
vfscanf( m_pFile, pcFormat, objArgs ); // m_pFile is the file handle
va_end( objArgs );
}

this is actually wraping fscanf in File:can
kux
Reputation Points: 66
Solved Threads: 11
Junior Poster
kux is offline Offline
119 posts
since Jan 2008
Feb 7th, 2008
0

Re: formated file reading problem

lol, it replaced : fs with the smiley , u know what i mean actually )
kux
Reputation Points: 66
Solved Threads: 11
Junior Poster
kux is offline Offline
119 posts
since Jan 2008
Feb 7th, 2008
0

Re: formated file reading problem

Did some research for you, and there is a workaround :

  1. #ifndef __stdio_h__
  2. #include <stdio.h>
  3. #define __stdio_h__
  4. #endif
  5.  
  6. int vsscanf_s (const char * src, const size_t length, const char * format, va_list argList);
  7. int vsscanf_s (const char * src, const size_t length, const char * format, va_list argList)
  8. {
  9. return _snscanf_s (src, length, format, * (void **) argList);
  10. }
  11.  
  12. int vsscanf (const char * src, const char * format, va_list argList);
  13. int vsscanf (const char * src, const char * format, va_list argList)
  14. {
  15. return sscanf (src, format, * (void **) argList);
  16. }
Just throw that in the file where you're using vsscanf and it should work again.
If you use this code, use the vsscanf_s instead of the vsscanf if you want to avoid getting anoying "sscanf was declared deprecated" warnings.

Hope this helps. If it doesn't, post some sample data from your file and you'll get advice how to make your own function for it.

Niek
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Feb 7th, 2008
0

Re: formated file reading problem

Click to Expand / Collapse  Quote originally posted by kux ...
lol, it replaced : fs with the smiley , u know what i mean actually )
That's why we insist on people leaning to use CODE tags, as mentioned in the rules you read when you signed up.
Moderator
Reputation Points: 3275
Solved Threads: 890
Posting Sage
WaltP is online now Online
7,716 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Trying to learn from error messages(general error c10100b1)
Next Thread in C++ Forum Timeline: classes and inheritance problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC