Sign in to follow this  

passing string of chars to c string array?

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

This topic is 2630 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this