I'm having trouble formatting the string array that I got from a .txt file.
When I print the string, it comes out double spaced, when I only want it single spaced.
names.txt (file example)
1 2 3
|
Marry Ann Sue
John Davis Harley
Joseph Josh Jacob
|
So I take those lines and store them in a single variable.
1 2 3 4 5 6 7 8 9 10
|
char line1[30+1];
char line2[30+1];
char line3[30+1];
FILE * namefile;
namefile = fopen("names.txt"m "r");
fgets(line1, 31, namefile);
fgets(line2, 31, namefile);
fgets(line3, 31, namefile);
|
This all works, but I'm having a problem with the formatting.
I need it in a format where it prints as such:
Edit: Please imagine that the asterisks create a rectangle
1 2 3 4 5
|
************************
* Marry Ann Sue *
* John Davis Harley *
* Joseph Josh Jacob *
************************
|
So I tried doing this and a few other methods, but it kept double spacing.
1 2 3 4 5
|
#define FORMAT "* %30s *\n";
printf(FORMAT, line1);
printf(FORMAT, line2);
printf(FORMAT, line3);
|
but it just comes out like this
1 2 3 4 5 6 7 8
|
********************
* Marry Ann Sue
*
* John Davis Harley
*
* Joseph Josh Jacob
*
************************
|
Anyway I can get rid of the double spacing? I just want everything to be single spaced.