its 5:30am here (these late nights are becoming common ><
so im tired but at a quick glance i cant instantly see the problem with your strcat. I can, however, offer an alternitive which greatly reduces the amount of code, is more flexiable and as far as i know is the safest way to handle string combining and variable conversion to string.
sprintf() is the command I would suggest you use, to gain access include stdio.h (standard in-out).
The command will take a destination string as its first parameter and the second string will be a special string constant that can contain special tokens relating to variables you wish to put in there and also how to act on them (sounds complicated, easy when you see it, keep on reading) - the third, fourth, ..., infinity parameter/s are variables you wish to insert to the string. There isnt a limit (that im aware of) of the amount of variables you can pass. Also, you dont have to pass ANY variables.
Example, first example without passing any variables and just writing text to a string assuming szText is an exisiting char array:
sprintf(szText, "Some Text");
simple stuff, will just make szText == "Some Text".
Now in your case you want to add an integer value to the string which is stored in "a". For this you use the %d token in the string and pass the a variable, like this:
sprintf(szText, "The value of A is: %d", a);
assuming A == 1, szText would now read like this: "The value of A is: 1"
you can put %d anywhere in the string and thats where A would appear. if you had a second integer called b, you could do this (slightly more complex example):
sprintf(szText, "A = %d, B = %d, A + B = %d", a, b, a + b);
you see how that works? its important to keep the variables you pass to the function in the same order as what you refrence in your constant string.
other tokens you can use are %f for a float and %s for a string and there will be a ton of others that i cant remember off top of my head but you can look up. brief example:
sprintf(szText, "an int: %d, an float: %f, some text: %s", nNumber, fNumber, "Some Text");
its good because you can get everything in on one line and it produces a solid and safe string - just make sure that szText is big enough to contain all the text you paste into it!
and one last thing briefly, theres other more advanced things you can do with tokens - imagine for example you were writing a game and storing the players score. The players score is stored in nScore, it currently equals 15 and you want to output it to the screen - except you want the final number to be 5 digits, padded with zeros - you could do this:
sprintf(szScoreOutput, "%05d", nScore);
szScoreOutput would now look like "00015" instead of just "15" - if nScore become 250 then it would look like "00250" and for a score of 1500 it would be "01500" etc. Very usful, especially for digital clocks! you can change the number of zero's it pads to by changing the 5, so "%03d" would make it pad to 3 zero's.
Tons more stuff you can do like trimming some of the numbers off the decimal point of a float etc, do look up the command, its probably my most used command in c++.
Sorry if you knew all this and for the long winded explination, if you knew then this hasnt hurt you and if you didnt you should now know everything you need to
Finally, your code using sprinf:
#include "DarkSDK.h"
#include "stdio.h"
void DarkSDK ( void ) {
dbSyncOn();
dbSyncRate(40);
char szText[512];
int a=0;
while (LoopSDK() && !dbEscapeKey()) {
sprintf(szText, "The value of a is: %d", a);
a++;
dbSetCursor(0,0);
dbPrint(szText);
dbSync();
}
}
i'm sure someone will be along soon to say why the strcat method was exploding on you