Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Craazer

Is it bossible to pass string as param to this func?

This topic is 5593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, if I have string can I anyway pass it to that function below? I tryed using c_str() but obiously that doesn''t work.
  
void Cout(char* str)
{
 cout<<str;
}
  
Please don''t say use char, the problems this.

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by DerekSaw
How about:

void Cout(const char *str)
{
cout << str;
}



Ah! so simble (what was I thinking?) Thanks man!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
or better yet
Cout((char*)string.c_str());

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

or better yet
Cout((char*)string.c_str());



How''s that better?

Share this post


Link to post
Share on other sites
quote:
Original post by Craazer
Ah! so simble (what was I thinking?) Thanks man!



Is the 'P' letter missing in your keyboard?
And for your question, yes you can.

[edited by - xaxa on March 25, 2003 4:24:50 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
or better yet
Cout((char*)string.c_str());


c_str() already returns a char*, why would you want to cast it?

Share this post


Link to post
Share on other sites
no, it returns a const "char*". don''t cast the const away unless you really have to and know it is safe in the expression you use it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!