Jump to content
  • Advertisement
Sign in to follow this  
nuclear123

passing string of chars to c string array?

This topic is 2912 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

void stringg(char buffer[100])
{
std::cout << *buffer; //display is just showing the "s" i want it to show "string"
getchar();
}

int _tmain(int argc, _TCHAR* argv[])
{
stringg("string");
return 0;
}

how do i pass this whole string value into my stringg functions first parameter? and then display it without haveing to iterate thru the array?

Share this post


Link to post
Share on other sites
Advertisement
you can construct a string object using the passed array. you can use printf instead of cout. you can iterate like you suggested.

but seeing as you are using c++, you could define your function thusly:
void stringg(const std::string &str)
{
std::cout << str;
getchar();
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!