Strange result

I am new to programming, and still a learner in C++...i had written a basic program from the tutorial on this very web site. However once i executed the program i got ' smiley ' faces along with the numericals , so i removed the char function and then executed obtaining only numericals this time as expected. Is this a glitch of some sorts? And by the way...the reason for the usage of the char function was because, at the end of the ' countdown ' a comma comes after the number 1...i wanted that not to happen. So for that i tried to allot a variable specially for ' 1 ' and print it separately so as to 'remove' the comma. Please excuse my amateur nature as i am still learning :).

the program:-

#include <iostream>
using namespace std;
int main()
{
char m;
int n;
m = 1;
for ( n = 10; n>0 ; --n){
if ( n == 1 ) continue;
cout << n << ", ";
cout << m;
}
cout << "FIRE!";
std::cout << "Press ENTER to continue...";
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
return 0;
}

--------------------------------------------------------------------------------
std::cout << "Press ENTER to continue...";
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );

I had to use this piece of code which i took up from this very forum , as my console would not display the output screen for longer than a second...as in, it would not 'stay'. This piece of code isn't my own.

You're seeing what the console chose as the graphical representation of the ASCII value 1. If you want to see that as an integer, you first need to convert it:
std::cout <<(int)m<<std::endl;
If you instead want to see it as a character, assign it a value that isn't an ASCII control character. For example, 65.

as my console would not display the output screen for longer than a second
Have you tried actually opening a console and navigating to the directory where you compiler put the program?
For example, if I want to run a program from a project called SDL, this is what I do:
Windows key+R, "cmd", enter key,
cd "F:\Documents and Settings\root\My Documents\Visual Studio 2008\Projects\SDL\bin\"
program.exe
(program runs and console stays there after it finishes)
Last edited on
Thank you Helios, i was thinking it was some sort of glitch!
Topic archived. No new replies allowed.