Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Buffer overrun when loading image  (Read 3395 times)

0 Members and 1 Guest are viewing this topic.

Devil0150

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Buffer overrun when loading image
« 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?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Buffer overrun when loading image
« Reply #1 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.
SFML / OS X developer

Devil0150

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Buffer overrun when loading image
« Reply #2 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.

Core Xii

  • Jr. Member
  • **
  • Posts: 54
    • MSN Messenger - corexii@gmail.com
    • AOL Instant Messenger - Core+Xii
    • View Profile
Buffer overrun when loading image
« Reply #3 on: August 25, 2009, 03:16:30 pm »
Quote from: "Hiura"
// is for comment


// isn't a comment when it's inside a string.

Devil0150

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Buffer overrun when loading image
« Reply #4 on: August 25, 2009, 03:45:54 pm »
I know. Any idea about what I asked?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Buffer overrun when loading image
« Reply #5 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?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Devil0150

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Buffer overrun when loading image
« Reply #6 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.