Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int wrap( const char* in, char* out, int bound )
- {
- int i, j, track;
- int spaced = 0, spacedj = 0;
- i = j = track = 0;
- for( i = 0; in[i] != 0; i ++ )
- {
- out[j] = in[i];
- if( in[i] == ' ' ){
- spaced = i;
- spacedj = j;
- }
- j++;
- track++;
- if( track > bound )
- {
- if( spaced != 0 ){
- out[spacedj+1] = '\n';
- i = spaced;
- j = spacedj+2;
- }
- else
- out[j++] = '\n';
- track = 0;
- spaced = 0;
- spacedj = 0;
- }
- }
- out[j] = 0;
- return j;
- }
Advertisement
Add Comment
Please, Sign In to add comment