Notices
The Basement Non-Honda/Acura discussion. Content should be tasteful and "primetime" safe.

C++ Help v.STD to System

Thread Tools
 
Old Dec 6, 2006 | 06:21 PM
  #1  
M@rshy's Avatar
M@rshy
Thread Starter
٩(̾●̮̮̃̾•̃̾)۶
 
Joined: Aug 2004
Posts: 21,807
Likes: 0
Default C++ Help v.STD to System

I don't know if theres anyone on HAN that knows much C++ or anything.

I'm working on a final project. My partner and I are making a calculator. I'm doing the dialog and hes doing most of the functions. The functions are using namespace STD while my dialog is using a namespace that Visual Studio made. I'm making my dialog with Windows Forms.
What I need to do is pass System::string to std::string and then std::string to system::string. Is this possible? Can anyone shed some light on this or toss out some code snippets?
Reply
Old Dec 6, 2006 | 06:37 PM
  #2  
M@rshy's Avatar
M@rshy
Thread Starter
٩(̾●̮̮̃̾•̃̾)۶
 
Joined: Aug 2004
Posts: 21,807
Likes: 0
Default

I read somewhere that if I use this:
Code:
std::string my_string = "Some text";
System::String* string = my_string.c_str();
it should work. However my string is in the private section of a class. Normally I would just go c.get_ans() and it would return the string.
I tried
Code:
 System::String* ans1 = c.get_ans().c_str();
but it still says "error C2440: 'initializing' : cannot convert from 'const char *' to 'System::String ^'"



Edit: Nobody knows C++? Damn...
Reply
Old Dec 6, 2006 | 06:38 PM
  #3  
Brar's Avatar
Brar
|:]
 
Joined: Aug 2004
Posts: 14,182
Likes: 0
Default

I remember when I wanted to learn C before 8th grade... I said fuck it one day in h:
Reply
Old Dec 6, 2006 | 06:39 PM
  #4  
IluvJae's Avatar
IluvJae
Grifball Player
 
Joined: Aug 2004
Posts: 27,249
Likes: 0
From: Foundry
Default

SHIT...i made a calc in C++ lemme see if i can find the program.
Reply
Old Dec 6, 2006 | 06:42 PM
  #5  
M@rshy's Avatar
M@rshy
Thread Starter
٩(̾●̮̮̃̾•̃̾)۶
 
Joined: Aug 2004
Posts: 21,807
Likes: 0
Default

I tried making it with Windows Application but it was fucked up and screwy.
I'm going to have to see if my prof can shed some light.
Reply
Old Dec 6, 2006 | 08:18 PM
  #6  
VPUPPY's Avatar
VPUPPY
Senior Member
 
Joined: Nov 2002
Posts: 1,975
Likes: 0
From: Orlando, FL
Default

c_str() returns a pointer to a constant. you are trying to initialize a non-constant variable to a constant. try setting the return value equal to a const variable to be used as a buffer possibly.
Reply
Old Dec 6, 2006 | 09:23 PM
  #7  
mayonaise's Avatar
mayonaise
Senior Member
 
Joined: Aug 2002
Posts: 3,181
Likes: 0
From: CA
Default

have you tried google?
http://blogs.msdn.com/slippman/archi...02/147090.aspx
http://msdn2.microsoft.com/en-us/lib...23(VS.80).aspx
http://www.google.com/search?q=conve...20std%20string
Reply
Old Dec 6, 2006 | 10:28 PM
  #8  
M@rshy's Avatar
M@rshy
Thread Starter
٩(̾●̮̮̃̾•̃̾)۶
 
Joined: Aug 2004
Posts: 21,807
Likes: 0
Default

I've looked at those Mayonaise. Thanks though.
Can I have a const pointer, pointing to the string I need? Would that fly?
Reply




All times are GMT -8. The time now is 09:02 PM.