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?
passing string of chars to c string array?
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();
}
but seeing as you are using c++, you could define your function thusly:
void stringg(const std::string &str)
{
std::cout << str;
getchar();
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement