 |
|
Kaak
|
|
If any of you are on that can help, please respond. time is of the essance!!!
|
|
|  |
 |
|
Kaak
|
|
quote:
#include
#define NUM_COLUMNS 80
main()
{
int maxChars = 9999;
char newLine[maxChars];
char data [maxChars];
int c=0, i=0, y=0, x=0, z=0, numChars=0, done=0, numSpaces=0 ;
int beginOfLine, temp;
while ((c = getchar()) != EOF)
{
if (c == '\t')
c = ' ';
data [x] = c;
++numChars;
++x;
}
if (numChars > NUM_COLUMNS)
for (i=NUM_COLUMNS-1; i <= numChars; i += NUM_COLUMNS)
{
numSpaces=0;
y = i;
while(data[y] != ' ')
y--;
data [y] = '\n';
// **************************************************
*******everything works above here
/* numSpaces = NUM_COLUMNS - y;
beginOfLine = i-NUM_COLUMNS+1;
for (z = beginOfLine; z < beginOfLine + NUM_COLUMNS+1; z++)
{
c=0;
newLine[c]=data[z];
while(numSpaces >=0)
{
/* c=0;
newLine[c]=data[z]; */
if (newLine[c]==' ')
{
temp=data[z+1];
newLine[c+1]=' ';
newLine[c+2]=temp;
c+=3;
z++;
numSpaces--;
}
else
{
c++;
z++;
}
}
printf("\n%s\n", newLine); */
}
}
printf("\n%s\n", data);
}
|
what i am trying to do is take input, from a file, or command line, break it off at 80 columns (if that is in the middle of a word, then i go back to the first space, and switch it for a new line char.
Then (and this is the part that doesn't work) i'm tring to justify each line to 80 chars by doubling the white spaces.
And that is where i have my problem...
|
|
|  |
 |
|
Kaak
|
|
one error in that code...the last close comment should be one bracker lower. Also, if you need a sample file, and a working version of the program, i can send it to you.
|
|
|  |
 |
|
Kaak
|
|
another mistake i made. I need to add the spaces before i'm adding the /n chars...
|
|
|  |
 |
|
Kaak
|
|
nevermind, it should work the way it is...
|
|
|  |
 |
|
Kaak
|
|
oh no, i know it doesn't work, i was just talking about the logic of it. i'll send you the samples...
|
|
|  |
 |
|
Kaak
|
|
i appreciate your help!!!
|
|
|  |
 |
|
Kaak
|
|
that is program she let us use to see how it was supposed to work. I don't have the source for it...I'll send you what i have
|
|
|  |
All times are GMT. The time now is 05:25. Apolyton Time is 00:25. |
top of page
|
| archivepost |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|