Jump to content

  • Log In with Google      Sign In   
  • Create Account

HaVoK87

Member Since 14 Dec 2011
Offline Last Active Sep 12 2013 08:57 PM

Topics I've Started

Basic C++ Help Maybe?

11 September 2013 - 04:07 PM

Okay I have a weird issue going on here that I can't seem to figure out. I must let you all know that I'm running Xubuntu 13.04 using gedit and g++ through terminal. Yeah this is how I wanted to start learning C++ and I was told this would be the best way. Here is my code.

// Game Stats
// Demonstrates declaring and initializing variables

#include <iostream>
using namespace std;

int main()
{
	int score;
	double distance;
	char playAgain;
	bool shieldsUp;

	short lives, aliensKilled;

	score = 0;
	distance = 1200.76;
	playAgain = "y";
	shieldsUp = true;
	lives = 3;
	aliensKilled = 10;

	double engineTemp = 6572.89;

	cout << "\nscore: " << score << endl;
	cout << "distance: " << distance << endl;
	cout << "playAgain: " << playAgain << endl;
	//skipping shieldsUp since you don’t generally print Boolean values
	cout << "lives: " << lives << endl;
	cout << "aliensKilled: "<< aliensKilled << endl;
	cout << "engineTemp: " << engineTemp << endl;

	int fuel;
	cout << "\nHow much fuel? ";
	cin >> fuel;
	cout << "fuel: " << fuel << endl;

	typedef unsigned short int ushort;
	ushort bonus = 10;
	cout << "\nbonus: " << bonus << endl;

	return 0;
}

Now when I try to compile in terminal this is the error I'm getting.

************~/Desktop/dev/src$ g++ gamestats01.cpp -o gamestats01
gamestats01.cpp: In function ‘int main()’:
gamestats01.cpp:18:14: error: invalid conversion from ‘const char*’ to ‘char’ [-fpermissive]
************~/Desktop/dev/src$ 

Can someone give me some insight on this? Also I have never programmed a day in my life. Is this okay for me to be using Linux and Terminal for starting? I hate Windows and would prefer not to touch it if I don't have to.


PARTNERS