Yes I was trying to keep it brief but I suppose I will just add the code to avoid confusion.
I believe it is a null terminated string of type char.
And yes I am trying to justify the output by adding spaces to the char array.
Code:
#include <stdio.h>
#include <string.h>
#define MAX_LINE_LEN 62
int output (char wbuf[]);
int space_check(int line_len);
int get_text(void);
int lbuf_len = 0;
char lbuf[62], *p = lbuf;
FILE *gettyText;
FILE *csis2;
int main(void){
p[0] = '\0';
fopen_s(&gettyText, "getty.txt", "r");
fopen_s(&csis2, "csis2.txt", "w");
get_text();
getchar();
return 0;
}
int get_text(void)
{
int n = 0;
extern char lbuf[62], *p;
char wbuf[60];
while (!feof(gettyText))
{
fscanf(gettyText, "%s", wbuf);
output(wbuf, n);
n++;
}
if(feof(gettyText)){
puts(lbuf);
}
return 0;
getchar();
return 0;
}
int output(char wbuf[], int n)
{
int line_len, spaces_needed;
extern int lbuf_len;
int wordLength;
extern char lbuf[62], *p;
char i[2], *j;
spaces_needed = 0;
wordLength = strlen(wbuf); // determines the size of the word
// printf("###%d###\n", wordLength);
lbuf_len += wordLength;
// printf("$$$$%d$$$\n", lbuf_len);
if(space_check(lbuf_len) > wordLength ){
// printf("%s", wbuf);
strcat(lbuf,wbuf);
strcpy (i, " ");
strcat(lbuf, i);
lbuf_len++;
//getchar();
// puts(lbuf);
}
if (space_check(lbuf_len) < wordLength)
{
spaces_needed = (strlen(lbuf) - 62);
printf("%d", line_len);
getchar();
fmt(spaces_needed);
puts(lbuf);
lbuf_len = 0;
p[0] = '\0';
//printf("Cleared space_remaining");
strcat(lbuf,wbuf);
strcpy (i, " ");
strcat(lbuf, i);
lbuf_len = strlen(wbuf);
//printf("Check new value of lbuf after it is cleared: %d", lbuf_len);
}
return 0;
}
int space_check(int lbuf_len){
int space_remaining;
space_remaining = MAX_LINE_LEN - lbuf_len;
//printf("%d Is the space remaining: ", space_remaining);
return space_remaining;
}
/*
int fmt(int spaces_needed){
int z = 0;
while (spaces_needed < MAX_LINE_LEN, spaces_needed++){ // Function to insert spaces into lbuf array
}
}
*/