Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Is there a way, when programming for the console in C++, to do a word wrap-like function. In which the words are moved to a new line if they cannot fit on the line they are on instead of being cut half way through and finished on another line. If ther is a way to do this, I'd really appreceate the help.
Thanks,
Pete Johnson

someone helped me with this question
before... here's the function... i call it
neatprint..void neatprint(FILE *fp, char string[], short maxLineWidth) {
short startIndex;
short endIndex;
short actualLineWidth;/* Do nothing if invalid inputs are received. */
if (fp == NULL || string == NULL || maxLineWidth = the ending index */
while (startIndex maxLineWidth) {
while (actualLineWidth > 0 &&
!isspace( string[ startIndex+actualLineWidth-1 ]) &&
!isspace( string[ startIndex+actualLineWidth ]) ) {
--actualLineWidth;
}
}
/* Output desired part of line. */
if (startIndex 0) {
fprintf(fp,"%.*s\n",actualLineWidth, &string[ startIndex ]);
}/* Move pointer to next section of buffer. */
startIndex += actualLineWidth;
}
}//syntax neatprint(stdout, chararray, 70);
Good Luckwww.akilla.tk

![]() |
Dynamic Variable Names
|
Real Player Tray Icon
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |