字符串到char * [英] String to char*

查看:81
本文介绍了字符串到char *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我可以将类型String转换为char * ??

我需要在我的应用程序中使用fstream和openfiledialog。


谢谢,


Maciek

解决方案

2005年一月一日 - 07-04在14:09 +0200,Maciej写道:

我可以将类型String转换为char * ??
我需要在我的应用程序中使用fstream和openfiledialog。



std :: string foo =" bar";

char * wombat = strdup(foo.c_str());


问候,


Leon Mergen


我的意思是String Class不是std :: string。


问候,


Maciek


U?ytkownik" Leon Mergen" ; <流明***** @ gmail.com> napisa3 w wiadomo?ci

news:11 ********************* @ localhost.localdomain ...

On Mon,2005-07-04 at 14:09 +0200,Maciej写道:

我可以将类型String转换为char * ??
我需要在我的应用程序中使用fstream与openfiledialog一起。



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

Leon Mergen



Maciej写道:


我的意思是字符串类不是std :: string。




1)请不要发帖。

把你的回复放在文本下面你回复了


2)C ++ *中的字符串类是* std :: string

标准C ++中没有其他字符串类。

如果你使用其他类,请询问那个

类的创建者怎么做,或者发布到那个类我的新闻组局部。

-

Karl Heinz Buchegger
kb * *****@gascad.at


Hallo,

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

Thanks,

Maciek

解决方案

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

U?ytkownik "Leon Mergen" <lm*****@gmail.com> napisa3 w wiadomo?ci
news:11*********************@localhost.localdomain ...

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



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
kb******@gascad.at


这篇关于字符串到char *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆