Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > String to char*

Reply
Thread Tools

String to char*

 
 
Maciej
Guest
Posts: n/a
 
      07-04-2005
Hallo,

Can I convert type String to char* ??
I need to use fstream in my application together with openfiledialog.

Thanks,

Maciek


 
Reply With Quote
 
 
 
 
Leon Mergen
Guest
Posts: n/a
 
      07-04-2005
On Mon, 2005-07-04 at 14:09 +0200, Maciej wrote:
> Can I convert type String to char* ??
> I need to use fstream in my application together with openfiledialog.


std::string foo = "bar";
char * wombat = strdup ( foo.c_str() );

Regards,

Leon Mergen

 
Reply With Quote
 
 
 
 
Maciej
Guest
Posts: n/a
 
      07-04-2005
I mean the String Class not a std::string.

Regards,

Maciek

Użytkownik "Leon Mergen" <(E-Mail Removed)> napisał w wiadomości
news:(E-Mail Removed) ...
> On Mon, 2005-07-04 at 14:09 +0200, Maciej wrote:
> > Can I convert type String to char* ??
> > I need to use fstream in my application together with openfiledialog.

>
> std::string foo = "bar";
> char * wombat = strdup ( foo.c_str() );
>
> Regards,
>
> Leon Mergen
>



 
Reply With Quote
 
Alan Johnson
Guest
Posts: n/a
 
      07-04-2005
Maciej wrote:
> Użytkownik "Leon Mergen" <(E-Mail Removed)> napisał w wiadomości
> news:(E-Mail Removed) ...
>
>>On Mon, 2005-07-04 at 14:09 +0200, Maciej wrote:
>>
>>>Can I convert type String to char* ??
>>>I need to use fstream in my application together with openfiledialog.

>>
>>std::string foo = "bar";
>>char * wombat = strdup ( foo.c_str() );
>>
>>Regards,
>>
>>Leon Mergen
>>

>
> I mean the String Class not a std::string.
>
> Regards,
>
> Maciek


(Reordered to undo top-posting.)

std::string and std::wstring are the only string classes provided by
standard C++.

-Alan
 
Reply With Quote
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      07-04-2005
Maciej wrote:
>
> I mean the String Class not a std::string.


1) Please don't top post.
Put your reply beneath the text you are replying to

2) the String Class in C++ *is* std::string
There is no other String Class in standard C++.
If you use some other class, please ask the creators of that
class how to do it, or post to a newsgroup where that class is topical.


--
Karl Heinz Buchegger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Torsten Mueller
Guest
Posts: n/a
 
      07-04-2005
"Maciej" <(E-Mail Removed)> schrieb:

> I mean the String Class not a std::string.


I've seen about 20 different String classes in my live. How about
looking into the list of methods of this class?

T.M.
 
Reply With Quote
 
Maciej
Guest
Posts: n/a
 
      07-04-2005
1) my mistake, sorry

I want to write a simple application using openfiledialog, and fstream.
I am not able to convert openfiledialog->filename to use it in open()
function of fstream. Filename is .net framework library String Class (MS
Visual Studio .Net).

Regards,

Maciek

Uzytkownik "Karl Heinz Buchegger" <(E-Mail Removed)> napisal w wiadomosci
news:(E-Mail Removed)...
> Maciej wrote:
> >
> > I mean the String Class not a std::string.

>
> 1) Please don't top post.
> Put your reply beneath the text you are replying to
>
> 2) the String Class in C++ *is* std::string
> There is no other String Class in standard C++.
> If you use some other class, please ask the creators of that
> class how to do it, or post to a newsgroup where that class is topical.
>
>
> --
> Karl Heinz Buchegger
> (E-Mail Removed)



 
Reply With Quote
 
Maciej
Guest
Posts: n/a
 
      07-04-2005
I have tried msdn.com, but it is very hard for me to find a relevant
function.

Maciek

Uzytkownik "Rolf Magnus" <(E-Mail Removed)> napisal w wiadomosci
news:dabamj$lqb$01$(E-Mail Removed)-online.com...
> Please don't top-post. Fixed.
>
> Maciej wrote:
>
> >> > Can I convert type String to char* ??
> >> > I need to use fstream in my application together with openfiledialog.
> >>
> >> std::string foo = "bar";
> >> char * wombat = strdup ( foo.c_str() );

> >
> > I mean the String Class not a std::string.

>
> std::string is C++'s string class. There is no class called "String" in
> standard C++. If you're using some other library that provides such a
> class, you better look into that library's documentation or ask in a
> newsgroup where that library is topical.
>



 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      07-04-2005
Please don't top-post. Fixed.

Maciej wrote:

>> > Can I convert type String to char* ??
>> > I need to use fstream in my application together with openfiledialog.

>>
>> std::string foo = "bar";
>> char * wombat = strdup ( foo.c_str() );

>
> I mean the String Class not a std::string.


std::string is C++'s string class. There is no class called "String" in
standard C++. If you're using some other library that provides such a
class, you better look into that library's documentation or ask in a
newsgroup where that library is topical.

 
Reply With Quote
 
benben
Guest
Posts: n/a
 
      07-04-2005
> I want to write a simple application using openfiledialog, and fstream.
> I am not able to convert openfiledialog->filename to use it in open()
> function of fstream. Filename is .net framework library String Class (MS
> Visual Studio .Net).


Try System::String::ToCharArray()

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemstringclasstochararraytopic.asp


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'System.String[]' from its string representation 'String[] Array' =?Utf-8?B?UmFqZXNoIHNvbmk=?= ASP .Net 0 05-04-2006 04:29 PM
Is "String s = "abc";" equal to "String s = new String("abc");"? Bruce Sam Java 15 11-19-2004 06:03 PM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 3 12-05-2003 04:20 PM
Re: String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 0 12-04-2003 04:40 PM



Advertisments