r/programminghelp • u/MildCutlery • Jul 04 '15
Help with a basic C++ program not working?
Keep in mind I'm using Code::blocks. This program runs without errors, but it just outputs a blank line when I try to run it. I sent my friend the code and he pasted it in to his Code::blocks, and it worked fine. The only difference between us is that I'm using windows and he's using Linux. All my other programs work.
//A program that outputs all characters with their ASCII codes.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int i;
while(i<=127){
cout<<char(i)<<" = "<<i<<endl;
i++;
}
}
0
Upvotes
2
u/Marvin4242 Jul 04 '15
Forgot to initialize i to 0, it starts off with a random value. Try i=0; before the loop.