Internal compiler error: Segmentation fault

I'm making a monopoly simulator and im trying to input proporty names and its giving me a segmentation fault. I have no idea what could be wrong so i wanted to see if you guys could help. Any suggestion?

Here is the input code.

GameLoop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "GameLoop.h"
#include "Rolling.h"
#include <iostream>

GameLoop::GameLoop()
{
	TileText = {"GO", "MEDITER-RANEAN AVENUE", "COMMUNUTY CHEST", "BALTIC AVENUE", "INCOME TAX", "READING RAILROAD", "ORIENTAL AVENUE", "CHANCE", "VERMONT AVENUE", "CONNECTICUT", "JAIL", "ST. CHARLES PLACE", "ELECTRIC COMPANY", "STATES AVENUE",
		"VIGINIA AVENUE", "PENNSYLVANIA RAILROAD", "ST. JAMES PLACE", "COMMUNUTY CHEST", "TENNESSEE AVENUE", "NEW YORK AVENUE", "FREE PARKING", "KENTUCKY AVENUE", "CHANCE", "INDIANA AVENUE", "ILLINOIS AVENUE", "B. & O. RAILROAD", "ATLANTIC AVENUE",
		"VENTNOR AVENUE", "WATER WORKS", "MARVIN GARDENS", "GO TO JAIL", "PACIFIC AVENUE", "NORTH CAROLINA AVENUE", "COMMUNUTY CHEST", "PENNSYLVANIA AVENUE", "SHORT LINE", "CHANCE", "PARK PLACE", "LUXURY TAX", "BOARD WALK"};
}

void GameLoop::Loop(int Loops){
	while(Loops > 0){

		Loops--;
	}
}

GameLoop::~GameLoop()
{
	//dtor
}


GameLoop.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef GAMELOOP_H
#define GAMELOOP_H

#include <iostream>

class GameLoop
{
	public:
		std::string TileText[40];
		int Tiles[40];
		GameLoop();
		void Loop(int Loops);
		virtual ~GameLoop();
	protected:
	private:
};

#endif // GAMELOOP_H 


Ok now i updated code::blocks and now its saying its a GameLoop.cpp 10 error: assigning to an array from an initializer list. Do you know what wrong now.
Last edited on
What compiler are you using? If it's not from within the last decade, ditch it.
Regardless of the errors in the program (specifically line 7 is invalid), an internal compiler error is always a bug in a compiler that should be reported (if your version is the latest one)

As for making it valid C++, if you have C++11 enabled, you can initialize the array like any other member of a class, in the member initializer list:
GameLoop::GameLoop() : TileText{"GO", "MEDITER-RANEAN AVENUE" ..."} {}
otherwise, fill the array using std::copy or similar.
however, does every instance of GameLoop really need its own array of seemingly identical strings?
Last edited on
LB, how should i input a array of strings if i cant do it this way?
Ok now i updated code::blocks and now its saying its a GameLoop.cpp 10 error: assigning to an array from an initializer list. Do you know what wrong now.
Topic archived. No new replies allowed.