I was attempting to convert my basic code into C++ and then continue from there. All seems well except I suspected issues with the strings.
So, I attempted a small and very simple program to concatenate two strings then print the result. I can print a
char*. I can print a
std:string. I can even print
agk::Str(a) (
a being whatever).
But as soon as I try to concatenate, the app/program will crash. No compile errors or any other error message except "the application has stopped working".
How did we go from the simple string manipulation of BASIC to the convoluted string nightmare in C++?? Python is more straight forward than C. None of the examples I have found for manipulating strings in C++ work. Even when I include the class such as <string>, <sstream>, <iostream> and any of the others described in the examples. (I didn't get a crash when I used
cout but also did not get a display.)
For example, here is one method that is suppossed to work for concatenating character strings. I have tried many different methods including strcat(), but all cause a crash.
agk::Print( agk::ScreenFPS() );
int a;
a = 12;
std::string tete = "Stage " + std::string(agk::Str(a));
std::stringstream ss;
char *ab = "";
ss << tete;
ss >> ab;
agk::SetTextString(15, ab); // text is already created, or try using print(), made no difference
agk::Sync();
The compiler will not let this happen:
agk::Print( agk::ScreenFPS() );
int a;
a = 12;
char *ab = "";
char *tete = "";
tete = tete+ agk::Str(a);
agk::Print(tete);
agk::Sync();
This will also cause a crash:
agk::Print( agk::ScreenFPS() );
int a;
a = 12;
char *ab = "Stage ";
char *tete = agk::Str(a);
strcat(ab, tete);
agk::Print(ab);
agk::Print(tete);
agk::Sync();
Yet, this does not:
agk::Print( agk::ScreenFPS() );
int a;
a = 12;
char *ab = "Stage ";
char *tete = agk::Str(a);
//strcat(ab, tete);
agk::Print(ab);
agk::Print(tete);
agk::Sync();
Merely trying to add strings together like in the straight forward BASIC or Python. I am trying to convert char to string, manipulate, then convert back string to char.
Does anyone else get crashes?
home.wavecable.com/~mindsclay