Hi, I'm trying to write a program that takes a text file as an output, and prints the text of that file to a column size defined by the user.
Here's my printing loop so far, when I run it, it just crashes the program. What should I change?
Code:
while ((fgets(fileChars, MaxLineSize, fp)) != NULL) // MaxLineSize is a #define to 100
{
stringLen = strlen(fileChars);
printf("%d", stringLen);
if (stringLen > columnWidth)
{
for (j = 0; j < columnWidth; j++)
{
printf("%s", fileChars[j]);
}
printf("\n");
for (j = columnWidth; j < stringLen; j++)
{
printf("%s", fileChars[j]);
}
}
else
{
printf("%s",fileChars);
}
}