Original Post
Hey there people from GameDev!
I'm a relatively new game developer, started learning C++ about 6 months ago. And I decided to do a simple string class exercise.
Now I'm running into a problem, I can't seem to get it to work without it crashing.
I'll post the pastebins for the code.
.h: http://pastebin.com/dbBWGDRV
.cpp: http://pastebin.com/tGSFz6K7
And finally, the main:
[source lang="cpp"]#include "CFString.h"
#include
int main(int argc, char* args[])
{
CFString bla = "hoi";
printf(bla);
return 0;
}[/source]
Now, it's crashing and I don't really understand why. Any pointers/hints?
EDIT:: I've tried to add a '0' after the strncpy, I've tried setting strdata to NULL.
I'm a relatively new game developer, started learning C++ about 6 months ago. And I decided to do a simple string class exercise.
Now I'm running into a problem, I can't seem to get it to work without it crashing.
I'll post the pastebins for the code.
.h: http://pastebin.com/dbBWGDRV
.cpp: http://pastebin.com/tGSFz6K7
And finally, the main:
[source lang="cpp"]#include "CFString.h"
#include
int main(int argc, char* args[])
{
CFString bla = "hoi";
printf(bla);
return 0;
}[/source]
Now, it's crashing and I don't really understand why. Any pointers/hints?
EDIT:: I've tried to add a '0' after the strncpy, I've tried setting strdata to NULL.