Hello,
I know there has got to be a simple way to do this, but I am trying to convert a string that was recieved using
getline (cin, string)
to a char array[].
the reason is because I have a function that acts as a type writer on the screen.
it is defined as
void typeout(char type[])
{
int limit = strlen (type)-1;
for (int index = 0; index <= limit; index++)
{
cout << type[index];
wait (250);
}
}
I hope someone can help me with this.
Thanks
Zack
Do you mean you want to get a c-like string from a string?
I think you can use function c_str() to do it.
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
#include <string>
int main () {
std::string str;
char *arr;
std::cin >> str;
strcpy(arr,str.c_str());
return 0;
}
| |
Last edited on