[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Is there a way to extract regular strings out of a wstring variable (without the pointer)?

Posted on 2006-04-30
7
Medium Priority
?
250 Views
Last Modified: 2013-12-14
Vecotr of wstring is crashing my programing becuase it wont take pointers, which wstring is a pointer.  My crrent vecor is declare as follow.  It's getting Uninitilize Memory in my Rational Purfiy program when I primaryGroups.Push_back().
It's also crashing my program.
      vector <std::wstring> primaryGroups;

I need to change the above declaration to a type of string that's not a pointer to a string.  Since all my code and data are in wstring for this, Is there a way to extract regular strings out of a wstring variable (without the pointer)?  And I sould be able to declare my vector of that type.

Thank you.
0
Comment
Question by:lapucca
  • 3
  • 3
7 Comments
 
LVL 15

Expert Comment

by:efn
ID: 16575072
> Vecotr of wstring is crashing my programing becuase it wont take pointers, which wstring is a pointer.

Why do you think this?  I think a wstring is not a pointer and there should be no problem with storing wstrings in a vector.  I suspect your problem is elsewhere.
0
 

Author Comment

by:lapucca
ID: 16575139
It's my understaind from previous posing here that wstring is (wchar_t*).  Answer given to me by another expert here.   It is equivalent use of PWSTR.  Thanks.
0
 
LVL 15

Expert Comment

by:efn
ID: 16575375
No, wstring is a class from the standard library, the basic_string template specialized for wchar_t.  You can initialize a wstring from an LPWSTR, which is a pointer to wchar_t, but they are not the same type.

http://msdn2.microsoft.com/en-US/library/wt3s3k55(VS.80).aspx

But anyway, you should be able to store either a pointer or a wstring in a vector without crashing your program.  You might consider constructing a minimal compilable demonstration of the problem.  If that exercise doesn't lead you to a solution, you will have something to post here.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 48

Expert Comment

by:AlexFM
ID: 16575408
Please show your code.
0
 

Author Comment

by:lapucca
ID: 16593069
So, is there no way to get a string out of wstring?  Something like getting BSTR out of _bstr_t?
0
 
LVL 15

Accepted Solution

by:
efn earned 2000 total points
ID: 16593333
0
 

Author Comment

by:lapucca
ID: 16602733
Thank you efn.  Those were great examples.  
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

834 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