sscanf warning

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

Join Date: Nov 2008
Posts: 78
Reputation: drjay1627 is an unknown quantity at this point 
Solved Threads: 1
drjay1627 drjay1627 is offline Offline
Junior Poster in Training

sscanf warning

 
0
  #1
Apr 24th, 2009
I'm looking for some help resolving the following warning...

warning: format ‘%c’ expects type ‘char*’, but argument 6 has type ‘char (*)[128]’

  1.  
  2. char data [ BLOCK_SIZE ];
  3. sscanf ( inBuf, "%c %c %c %c", &mode, &c, &s, &data );

essentially what happens is inBuf is a 'string' and I want mode, c, s and data to be what's in it.

'data' complains. Can someone help me fix it.

Thanks

drjay
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 390
Reputation: skatamatic will become famous soon enough skatamatic will become famous soon enough 
Solved Threads: 39
skatamatic skatamatic is offline Offline
Posting Whiz

Re: sscanf warning

 
0
  #2
Apr 24th, 2009
Originally Posted by drjay1627 View Post
I'm looking for some help resolving the following warning...

warning: format ‘%c’ expects type ‘char*’, but argument 6 has type ‘char (*)[128]’

  1.  
  2. char data [ BLOCK_SIZE ];
  3. sscanf ( inBuf, "%c %c %c %c", &mode, &c, &s, &data );

essentially what happens is inBuf is a 'string' and I want mode, c, s and data to be what's in it.

'data' complains. Can someone help me fix it.

Thanks

drjay
Do you have to use sscanf? That's a bit outdated and not generally used, and MSC++ throws a bunch of warnings when you use it. I sugguest using string datatype with operator+()

Usage:
  1. //Header
  2. #include<string>
  3.  
  4. //implementation
  5. string a, b, c, d;
  6. d = a + " " + b + " " + c + " ";
Last edited by skatamatic; Apr 24th, 2009 at 9:21 pm.
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