943,649 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 821
  • C++ RSS
Apr 24th, 2009
0

sscanf warning

Expand Post »
I'm looking for some help resolving the following warning...

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

C++ Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 12
Solved Threads: 1
Junior Poster in Training
drjay1627 is offline Offline
87 posts
since Nov 2008
Apr 24th, 2009
0

Re: sscanf warning

Click to Expand / Collapse  Quote originally posted by drjay1627 ...
I'm looking for some help resolving the following warning...

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

C++ Syntax (Toggle Plain Text)
  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:
C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 352
Solved Threads: 108
Master Poster
skatamatic is offline Offline
772 posts
since Nov 2007

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: question
Next Thread in C++ Forum Timeline: Reading data from another file difficulty





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


Follow us on Twitter


© 2011 DaniWeb® LLC