I already posted this in the "word wrap" thread
here...
if you're looking for wordwrap in console,
look here.....
Code:
void mywordwrap(FILE *fp, char string[], short maxLineWidth) {
short startIndex;
short endIndex;
short actualLineWidth;
if (fp == NULL || string == NULL || maxLineWidth <= 0) {
return;
}
startIndex = 0;
endIndex = strlen(string);
while (startIndex < endIndex) {
while (startIndex < endIndex && isspace( string[startIndex] )) {
++startIndex;
}
actualLineWidth = maxLineWidth;
if (endIndex - startIndex > maxLineWidth) {
while (actualLineWidth > 0 &&
!isspace( string[ startIndex+actualLineWidth-1 ]) &&
!isspace( string[ startIndex+actualLineWidth ]) ) {
--actualLineWidth;
}
}
if (startIndex < endIndex && actualLineWidth > 0) {
fprintf(fp,"%.*s\n",actualLineWidth, &string[ startIndex ]);
}
startIndex += actualLineWidth;
}
}
//syntax mywordwrap(stdout, chararray, 70);
put the above function above your main function,
in main(), you have
char text[]="This is a text I am trying to print this long
text without having to break a word.";
you said you wanted a 50 char line....
so do this
mywordwrap(stdout, text, 50)
got it now ?
GOOD LUCK