Using putchar() for output, not printing out how I want
What my program does is read from a file and then prints out what is stored in an array.
Code:
7
67 7
XXX
X X
X
X
X
X X
XXX
49 5
X
XX
X
X
X
X
XXX
0
CC
That's the file it reads. first number at the top is the height of each character, then the first number above each letter/number is the character code. Second number is width. The 0 is the trigger number to start reading the input below it, and that's what it prints out, so it should be something like this
Code:
XXX XXX
X X X X
X X
X X
X X
X X X X
XXX XXX
but it prints out this...
Code:
XXX
XXX
X X
X X
X
X
X
X
X
X
X X
X X
XXX
XXX
Here is my output code:
Code:
for(int i=0;i<MAX_HEIGHT;i++)
{
for(int k=0;k<MAX_STRING&&charString[k]!=0;k++)
{
for(int j=0;j<MAX_WIDTH;j++)
{
if(j==1)
putchar(32);
int currentChar=charImage[charString[k]-32][i][j];
putchar(currentChar);
}
}
putchar(32);
}
Re: Using putchar() for output, not printing out how I want
Pseudo-code:
Code:
* read the input file and store the letters in matrixes
* max_height = maximum height of a letter
i = 0
while (i<max_height)
{
for each letter do
* print the i row
print new line;
i = i + 1
}