Skip to content

A few issue fixed to at least not segment fault on macos #25

@kwccoin

Description

@kwccoin

Not sure how you manage to run the program as you cannot return stack variable and use it ???
Anyway a temp fix is to allocate a global variable and then return the allocate string :

std::string s;
const char* getStrokeText()
{
	int biggestStroke = 0;
	if (balls[1].getStrokes() > balls[0].getStrokes())
	{
		biggestStroke = balls[1].getStrokes();
	}
	else
	{
		biggestStroke = balls[0].getStrokes();
	}
	//std::string 
	s = "";
	s = std::to_string(biggestStroke);
	s = "STROKES: " + s;
	return s.c_str();
}

const char* getLevelText(int side)
{
	int tempLevel = (level + 1)*2 - 1;
	if (side == 1)
	{
		tempLevel++;
	}
	// std::string 
	s = "";
	s = std::to_string(tempLevel);
	s = "HOLE: " + s;
	return s.c_str();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions