?
Solved

Issue with strings containing numbers in set container

Posted on 2014-03-25
2
Medium Priority
?
269 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

The Ideal Solution for Multi-Display Applications

Check out ATEN’s VS1912 12-Port DP Video Wall Media Player at InfoComm 2017. Kerri describes how easy it is to design creative video walls in asymmetric layouts and schedule detailed playlists ahead of time with its advanced scheduling feature.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
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…
Suggested Courses

765 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