Solved

Issue with strings containing numbers in set container

Posted on 2014-03-25
2
264 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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…

732 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