Hello all,

I'm giving a try to implement unix fmt( ) function which can be used

to format strings.Since I'm really new to C programming this doesn't

look like a pretty trivial problem to me. I'm trying to implement this

function in such a way where 80 characters per line.

I tried different ways but still I couldn't find a way to

implement all different possibilities.

for example I tried to divide the lines that can be found in a

paragraph in to:

2 different line groups -> lines exceed 80 characters

-> lines doesn't exceed 80

characters

etc.

I'll copy some sample code lineds I've been trying so far:

if(chkNL<80){

k=temp;

temp+=chkNL;

if(temp<80){

bufOut[temp]=' ';

bufInCount=0;

for(i=j; i<j+chkNL; i++){

bufOut[i]=bufIn[bufInCount];

bufInCount++;

}

j+=temp;

}

if(temp>=80){

for(i=0; i< chkNL-(temp-80); i++){

bufOut[k]=bufIn[i];

k++;

if(isalpha(bufIn[chkNL-(temp-80)+1])){

count=0;

while(!(isspace(bufOut[k]))){

bufOut[k]=' ';

k--;

count++;

}

....

.....

.....

If you have better implementation logic please let me (us) know.

thanks in advance.