Hey guys, I am trying to write a function that displays wrapped text, but it doesn't work.
void WrapText( char Text[256], int x, int y, int Width )
{
int CursorX = x; // x position to begin drawing text
int CurrentChar = 0; // Current character to look at
char Line[256] = {0}; // The string which will hold a single line's contents
// While the cursor position is to the left of the right margin
while ( CursorX < Width )
{
// Set the line char equal to the input text char
Line[CurrentChar] = Text[CurrentChar];
// Increment the current char
CurrentChar += 1;
// Estimated width of a character, in pixels
CursorX += 4;
}
// Draw the text
dbText( x, y, Line );
}
I then proceed to call the function with this:
WrapText( "This is a test of the wrapping text function.", 450, 110, 100 );
However, the function prints nothing. If I don't null the 'Line' string, it prints some garbled text.
Any idea what I'm doing wrong?