[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Issue with strings containing numbers in set container

Posted on 2014-03-25
2
Medium Priority
?
272 Views
Last Modified: 2014-03-25
I cannot retrieve any string from a set container if the string has numbers in it. I am able to successfully retain any string that contain only characters, but if I add a string to the container that contains even one number I receive an error when trying to retrieve it using wprintf(). See my code below:

typedef basic_string<wchar_t> tstring_t;
typedef set<tstring_t> tset_t;
tset_t groupsFound;

wchar_t bufName[MAX_PATH]; (this is populated by another function)

groupsFound.insert(bufName);

_tprintf(_T("# of elements in groupsFound: %i\r\n"), groupsFound.size());

for (tset_t::iterator it=groupsFound.begin(); it!=groupsFound.end(); ++it)
{
	_tprintf(_T("%s\n"), *it);
}

Open in new window

0
Comment
Question by:tr57285
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
chaau earned 2000 total points
ID: 39955031
Please use
_tprintf(_T("%s\n"), (*it).c_str());

Open in new window

Using the tstring_t class (or any other class) is never safe as a const char* replacement with the argument list in the format.
0
 

Author Closing Comment

by:tr57285
ID: 39955083
This worked perfectly, thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Progress

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question