CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    57

    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);
          }

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    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
    }
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured