while(TextSize > 200)//if our text size if greater than 600
{
char test[1]= {'\0'};//our character zeroed for easy memcpy
size_t StringLength =0;//this holds the size of our string
StringLength = strlen(NewString);//get our string length
TextSize = GetSizeForString(NewString);//get the text size we would output in pixels
test[1] = NewString[StringLength-1]; //copy that string
NewString[StringLength-1] = '\0'; //make it blank now
strncat(Line2, test, 1);
MoreLines = true;
}
the GetSizeForString function just returns the pixel size of the string to be output
NewString is our unmodified String Line2 is supposed to be the string all the extra characters are being output to..
[Edited by - yewbie on August 17, 2008 3:42:02 PM]
[C] Trouble appending last character of a string to a new string :/
Maybe I'm just tried but I cannot seem to figure out what I am doing wrong here :/
What I am doing is taking a string and slicing off 1 character at a time until enough has been cut off to fit in my space then copying everything that I sliced off to a new string and here is how im doing it maybe someone can see something I missed (I'm not all that great of a programmer so it could just be something I don't know!)
Heh sorry for the post I fixed it :/
it needed to be
test[0] = NewString[StringLength-1]; //copy that string
I was just copying the wrong part!
it needed to be
test[0] = NewString[StringLength-1]; //copy that string
I was just copying the wrong part!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement