Hello,
I don't exactly understand what you want to do, but I'm guessing you want to make a console application that shows a random description of a character.
I'm not following what your program really does, but, if the console is showing a smiley face, most probably you have an integer holding the value 1 and then you treat it as a character instead of an integer, so when you do that, the character whose ascii code is 1 is shown, which is the smiley. I noticed this once when I tried to convert an integer to a char to see what happens :P
Other than that, I'd like to say: Don't use using namespace std; even if it appears in most documentations. If you want to do something like a header and you use using namespace std; you may have problems with your program (especially if someone else uses your library), and it's not that hard to learn to not use it. Libraries like iostream and string.h have everything in the namespace std (like cout and cin, or endl), so you have to access it adding std:: on its left. It may look weird to you, but it's how it works. Don't use using namespace std;
Another thing you really shouldn't do is to use system(). I don't know why we all do it when we start, but it's a bad practice for many reasons, including security vulnerabilities, compatibility problems (will only work under windows), and more stuff. You have to learn to use C++ without system(). Just think about it, isn't using batch in your C++ code... how would you call it...
Instead of system("pause"); you can #include <conio.h> and then use getch();
Another practice you should do is to use tabs (or spaces) inside each block between {}, otherwise when you write a long code you won't easily read where every thing is, if you do this, you'll be able to see your program flow easier. Like this:
1 2 3 4 5 6 7 8 9 10
|
int main()
{
//...
if (i == 2)
{
a = 1;
}
//...
return 0;
}
| |
There is more stuff to point out, but it's stuff you will learn in the tutorial - such as using switch() - so I won't explain it here, you will eventually learn it yourself. I'm telling you this because it doesn't come in the documentation, and these are errors that happen usually to beginners and someone has to point them :)