SFML community forums

Help => Graphics => Topic started by: Devil0150 on August 25, 2009, 01:35:28 pm

Title: Buffer overrun when loading image
Post by: Devil0150 on August 25, 2009, 01:35:28 pm
Code: [Select]
Piece::Piece()
{
imgPiece.LoadFromFile("C://Documents And Settings//User//My Documents//My Pictures//piece.bmp");
sprPiece.SetImage(imgPiece);
}


I am using visual c++ 2008 and when I start the program I get a buffer overrun on the this line:

Code: [Select]
imgPiece.LoadFromFile("C://Documents And Settings//User//My Documents//My Pictures//piece.bmp");

I even tried \\ instead of //. It still doesnt work.

What did I do wrong?
Did I miss something on the tutorials?
Title: Buffer overrun when loading image
Post by: Hiura on August 25, 2009, 01:39:00 pm
// is for comment
If you want to write '/' you only need to write '/'. If you want to write '\' you have to write '\\'.

Does your code compile ? It should not.

This is wrong in some cases, sorry.
Title: Buffer overrun when loading image
Post by: Devil0150 on August 25, 2009, 01:42:16 pm
Inside double quotes / and // is the same. The text doesnt get green (comment color) even if I use //. And Yes, the Code compiles.
Title: Buffer overrun when loading image
Post by: Core Xii on August 25, 2009, 03:16:30 pm
Quote from: "Hiura"
// is for comment


// isn't a comment when it's inside a string.
Title: Buffer overrun when loading image
Post by: Devil0150 on August 25, 2009, 03:45:54 pm
I know. Any idea about what I asked?
Title: Buffer overrun when loading image
Post by: Nexus on August 25, 2009, 06:34:48 pm
Quote from: "Hiura"
Does your code compile ? It should not.
Why not? String literals aren't checked at compile time.

Quote from: "Devil0150"
Inside double quotes / and // is the same.
No, it is definitively not the same. Accordingly, your path containing double slashes is invalid.

Quote from: "Devil0150"
I know. Any idea about what I asked?
What do you exactly mean with "buffer overrun"? Which buffer is overrunning? What error message do you get?
Title: Buffer overrun when loading image
Post by: Devil0150 on August 25, 2009, 06:50:00 pm
Quote
Devil0150 wrote:
Quote
Inside double quotes / and // is the same.

No, it is definitively not the same. Accordingly, your path containing double slashes is invalid.

I meant none of them makes the text a comment. The error message says:

Code: [Select]
A buffer overrun has occurred in Program.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

For more details please see Help topic 'How to debug Buffer Overrun Issues'.


But I fixed it. It happened because the first time I compiled the code, I got some warnings. And I tried to remove them by removing the -d from the stuff I put in the Linker. The warnings were removed but thats when the buffer error started to show. Now that I put the -d, the buffer overrun error doesnt happen anymore.