I am given a poem in a text file, and I have to
1. store all lines in a character matrix
2. Find the number of characters in the longest line
3. Write the lines to a new text file, but add the line number for every 5th line, aligned on the right hand side.
It should look something like this:
This is a poem
Poem Poem Poem Poem
Poem Poem Poem Poem
Poem Poem Poem Poem
Poem Poem Poem Poem 5
....
I am completely lost, this is what I have so far.
This doesn't even print the lines right, can anyone please help me?Code:FILE *fp; char *StrArr[100]; fp = fopen("myFile.txt", "r"); int i; for( i=0; i<100; i++) { fscanf(fp, "%s\n",&StrArr[i]); printf("%s",&StrArr[i] ); }
Thanks a lot!



1Likes
LinkBack URL
About LinkBacks




