I've read and re-read my manual, and have tried to come up with the proper search terms (But none come to mind), so I'm forced to be the imbecile with a newbie question-
It seems that this while loop does not pertain to loop logic; this is a run-time error I cannot get my head around. Perhaps it's merely some loop logic leftover from my days of BASIC, though.
Here's the snippet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main()
{
int numchar = 6;
cout << "+";
while (numchar > 0)
{
numchar - 1;
cout << "~";
}
cout << "+";
return 0;
}
|
Upon having it output the value of "numchar," rather than the "~," it never changes from 6 to 5, to 4, and so forth. According to the book I'm reading (Written in 2010, for Windows; I'm using Linux) it looks like it should work...
The result should be:
But it is:
And it continues indefinitely.
Upon having it output the value of "numchar," rather than the "~," it never changes from 6 to 5, to 4, and so forth. According to the book I'm reading (Written in 2010, for Windows; I'm using Linux) it looks like it should work...
What am I doing wrong? Thanks in advance!