Added code tags to your post. Please use them in the future.
I recommend not using Raid's tutorials, they're useless.
Anyway, you're declaring integers. You're trying to use numbers, rather than strings, in other words. Also, you're dynamically assigning "string1" to "string1", when no member called string1 has been declared. Same with "string2".
You also don't need to use globally scoped variables. Just variables in main() will do.
Code:
#include <iostream>
using namespace std;
int main ()
{
char string1[80];
char string2[80];
cout << "What's your name?" << endl;
cin >> string1;
cout << "Hello " << string1 << endl;
cout << "Do you have a favorite color?" << endl;
cin >> string2;
cout << "I think the color " << string2 << " is cool" << endl;
return 0;
}
I prefer to use the C functions known as printf() and scanf(), however I guess it's a matter of preference.
strings are character arrays. What Raid's tutorial uses is the string class, which though usable, isn't really preferable.
I noticed Raid's Tutorial isn't really a tutorial. Anyway, I changed the script and ran the program, but when i type in my name it would respond Hello0 instead of Hello(name). It also does the same thing with the color. Any suggestions?
I noticed Raid's Tutorial isn't really a tutorial. Anyway, I changed the script and ran the program, but when i type in my name it would respond Hello0 instead of Hello(name). It also does the same thing with the color. Any suggestions?
That may be true, but make sure you actually understand what's going on now or you've gained nothing from it. Feel free to ask questions should anything trouble you.
That may be true, but make sure you actually understand what's going on now or you've gained nothing from it. Feel free to ask questions should anything trouble you.