This seems like something pretty basic, and I'm sure I'm just missing something, but I can't figure it out.
I've been searching for a bit, and find several different suggestive solutions, but none of them were working for me. I'm sure I was doing something wrong.

What I want to is basically this:

int score = 47;
textout_ex(screen, font, "SCORE:   " + score, 495, 240, RED, BLACK);

Any help is appreciated!

So what's wrong? And don't say "it doesn't work" we know that.

So what's wrong? And don't say "it doesn't work" we know that.

It doesn't work.

The problem is that it is printing out something that looks like "mismatch" instead of score's value.

It's printing out the word "mismatch"? That's weird.

What are the parameters for the function -- how are they defined in the prototype?

What are the parameters for the function -- how are they defined in the prototype?

What function? textout_ex?
I don't clearly understand your question.

textout_ex is a function in the Allegro library, that Writes a string on a bitmap.

Here's its prototype:

void textout_ex(
BITMAP *bmp, const FONT *f, const char *s, int x, int y, int color, int bg);

More information HERE.

I understand how to use textout_ex, but I don't understand how to get it to print the variable score's value in line with another string...like the example I posted. It looks correct to me, but I'm new to c++.

What function? textout_ex?
I don't clearly understand your question.

Of course textout_ex . Is there another function in the code you posted?

kim0000 gave me the answer....

How is the third parameter defined in the prototype kim0000 posted?
Does the third parameter in your call fit that definition? That is the type of "SCORE: " + score ?

but I don't understand how to get it to print the variable score's value in line with another string...like the example I posted. It looks correct to me, but I'm new to c++.

Do you mean this:

int score = 47;
string Str;
stringstream out; // YOU MUST INCLUDE <sstream> FOR THIS.
out << score;
Str = out.str();

cout << "SCORE: " + Str; // TEST: Will print out "SCORE: 47".

You can't do: some_string + some_int
So This way is to store score into Str converting it from int to string

... but I don't understand how to get it to print the variable score's value in line with another string...

you can't add an integer to a character array. You need to convert the integer to a character array then concatinate them. Kim has one way, ssprintf() is another (may be easier, but older C-style code). Research how your book converts ints to chars and see what you can come up with.

I tried something with cout earlier, but it wouldn't work. I was likely doing something wrong. I seem to follow your example, so I will give that a shot when I resume in the morning.
Thanks for the kind help, Kim. It is greatly appreciated. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.