• Advertisement
Sign in to follow this  

passing string of chars to c string array?

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