simple word wrap problem not wrapping
From: Douglas G (dgardiner_at_houston.rr.com)
Date: 08/31/04
- Next message: Keith Thompson: "Re: Will EXIT_SUCCESS and EXIT_FAILURE have the same value on all platforms?"
- Previous message: junky_fellow: "Re: addresses and integers"
- Next in thread: Malcolm: "Re: simple word wrap problem not wrapping"
- Reply: Malcolm: "Re: simple word wrap problem not wrapping"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 Aug 2004 05:33:35 GMT
I've tried various ideas on this problem, but I don't see word wrapping.
Can you point out what is wrong? It's a K&R exercise, and I'm still new to
programming. Other pointers would be helpful too.
#include "header.h"
/* does the wordwrapping */
void fold(char buffer[], int len)
{
int start_point,i;
start_point=i=0;
while (len > (start_point +COLUMN)) {
i=start_point+COLUMN;
while ( buffer[i]!=' ' || buffer[i]!='\t')
start_point=--i;
buffer[++i]='\n';
}
start_point=i=0;
return;
}
[snippet from header.h]
/* header.h */
#include <stdio.h>
#define MAXLINE 1000 /* maximum input line size */
#define COLUMN 35 /* length before fold */
- Next message: Keith Thompson: "Re: Will EXIT_SUCCESS and EXIT_FAILURE have the same value on all platforms?"
- Previous message: junky_fellow: "Re: addresses and integers"
- Next in thread: Malcolm: "Re: simple word wrap problem not wrapping"
- Reply: Malcolm: "Re: simple word wrap problem not wrapping"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|