first, I'm using visual studio express 2012, with the sfml2.2.
I've trying to convert from sf::String to std::string. Basically I want user to input numbers, convert those numbers to int and then perform various calculations based on the input.
However every-time I run toAnsiString(), I get an error during the operator delete. The error is:-
(http://i61.tinypic.com/33cay51.png)
When I press retry and I look into the stack, I see that the first entry in the stack is below.
(http://i58.tinypic.com/oucetx.png)
Then the next stack entry up is below:
(http://i57.tinypic.com/21kgnwz.png)
And then I see the operator delete in the next one.
(http://i60.tinypic.com/2ic1l42.png)
My code is extremely basic as I've scaled it right back now to try to determine what I am doing wrong. I'm still very new to programming so help appreciated....with basic instructions. :) I have double checked to ensure that sfml lib are linked correctly, i.e. I ensure I didn't mix up -d libs in the release configuration and vice-versa.
Here is my code. first my header
#ifndef TEST_H
#define TEST_H
#include <string>
#include <SFML/Graphics.hpp>
using namespace std;
class testClass
{
public:
testClass();
void testSFString();
bool chkStr();
private:
sf::String SFStr;
std::string stdStr;
};
#endif
Then my source file.
#include "test.h"
testClass::testClass()
{
}
void testClass::testSFString()
{
SFStr = "testStr";
if (chkStr())
{
stdStr = SFStr.toAnsiString(); //dies here
}
}
bool testClass::chkStr()
{
if (!SFStr.isEmpty())
return true;
else
return false;
}
finally my main
#include "test.h"
int main()
{
testClass test;
test.testSFString();
}
Make sure that you don't use release libraries in debug mode. And that you're using the VS 2012 SFML libraries for x86.
Hi,
The sfml zip file that I downloaded is called "SFML-2.2-windows-vc12-32-bit.zip" - so this does look like the VC2012 32 bit files. I have other sfml programs that work fine, however this is the first time I've tried to convert a sf::string to the std::string.
For the other libs. I re-checked the project properties. I went to Linker -> Input.
Under Debug I have the below as additional dependencies
"tgui-d.lib;sfml-main-d.lib;sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;sfml-audio-d.lib;sfml-network-d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)"
Under Release I have the below
tgui.lib;sfml-main.lib;sfml-graphics.lib;sfml-window.lib;sfml-system.lib;sfml-audio.lib;sfml-network.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
I don't see any mix-up? Unless you can see something?