How do you store whole sentences in a variable?
I want to print out sentences using variables. I tested with a 'string' data type and stored individual sentences as an element then used a 'for' function to print them with a delay between each sentence. The result is an error, upon building it, saying
at this line:
Full code:
I want to print out sentences using variables. I tested with a 'string' data type and stored individual sentences as an element then used a 'for' function to print them with a delay between each sentence. The result is an error, upon building it, saying
"invalid conversion from 'const char*' to 'char'
t1[3] = {"Hello!", "This is a test for my program.", "\nI hope you're havin fun reading this!"};
Code:
#include <iostream>
#include <string>
#include <windows.h>
// A function to make text that'll play automatically.
void playText() {
using namespace std;
string t1[3];
t1[3] = {"Hello!", "This is a test for my program.", "\nI hope you're havin fun reading this!"};
for(int i = 0; i < 3; i++) {
cout << t1[i];
Sleep(1000);
}
}
int main() {
using namespace std;
cout << "Starting program...";
playText();
cout << "Done!";
return 0;
}
Comment