Integer displaying crazy numbers issue
O.K. First off I would like to explain that I am making a simple game. I check my syntax, and I check it often. I thought at first my problem only existed in my game code, but I then found out through testing that it is with all code. I am using Dev-C++ (Newest Version) and here is a sample code. Try it and you will see what I mean.
Code:
#include <iostream>
using namespace std;
int main();
{int gold;
gold == 45;
cout<<"To display your current amount of gold hit the return key.";
cin.get();
cout<<"You currently have "<<gold<<" gold.";
cin.get();}
It displays 2 sometimes. At other times it displays like 21309874 or something like that. Somebody please help me!! :(
Errors all over the place
OK, so I entered the code, hit compile & run. Errors, errors, errors...Where have I gone wrong? :confused: Why can't it be easy! :(
Code:
#include<iostream>
#include <string>
using namespace std;
int main();
{
int gold, loseorgain;
gold = 1000;
start:
cout<<"Enter 1 to gain gold, or 2 to lose gold.";
cin>> loseorgain;
cin.ignore();
if (loseorgain==1){
gold+= 10;}
else if (loseorgain==2){
gold-= 10;}
Where is the freaking error? :(