formated file reading problem

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 119
Reputation: kux is on a distinguished road 
Solved Threads: 10
kux kux is offline Offline
Junior Poster

formated file reading problem

 
0
  #1
Feb 7th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 31
Reputation: Passmark is an unknown quantity at this point 
Solved Threads: 0
Passmark's Avatar
Passmark Passmark is offline Offline
Light Poster

Re: formated file reading problem

 
0
  #2
Feb 7th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 119
Reputation: kux is on a distinguished road 
Solved Threads: 10
kux kux is offline Offline
Junior Poster

Re: formated file reading problem

 
0
  #3
Feb 7th, 2008
Originally Posted by Passmark View Post
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 119
Reputation: kux is on a distinguished road 
Solved Threads: 10
kux kux is offline Offline
Junior Poster

Re: formated file reading problem

 
0
  #4
Feb 7th, 2008
lol, it replaced : fs with the smiley , u know what i mean actually )
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,818
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 296
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is online now Online
Roasting Maven

Re: formated file reading problem

 
0
  #5
Feb 7th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: formated file reading problem

 
0
  #6
Feb 7th, 2008
Originally Posted by kux View Post
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.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC