Thread: Creating a Box help!

  1. #1
    Registered User hungrymouth's Avatar
    Join Date
    Oct 2012
    Posts
    19

    Creating a Box help!

    Ok so my professor told us that he wanted us to create a box where Row, Column(shortening it using Col),Width,Height,and Color are variable.(He will be changing the values of those variables manually) So I did the box however to test to see that it will still make a perfect box no matter what numbers they are I changed the value of the original numbers I put which were (6 for Row,11 for Column,30 for Width,20 for Height,12 for Color) and now the box is a disaster please help I'm not sure how to fix it so the box will remain a box no matter what values I put!

    Boss.c is the source code(which is where one can change the values of the row,height,width,column,and color of the box)
    lebox.h is where the code is.

    Code:
     Boss.c
      
    #include <stdio.h>
    #include <stdlib.h>
    
    #include "screen.h"
    #include "lebox.h"
    
    int main()
    {
       Heading();
       SingleBox(6,11,30,20,12);
       PauseTheScreen();
    
    }

    Code:
     lebox.h
    void SingleBox(int Row,int Col,int Width,int Height,int Color)
    {
        int k;
        char UpperLeft[2],UpperRight[2],LowerLeft[2],LowerRight[2];
        char Vertical[2],Horizontal[2];
    
       _settextcolor(Color);
    
        UpperLeft [0] = 218;
        UpperRight[0] = 191;
        LowerLeft [0] = 192;
        LowerRight[0] = 217;
        Vertical  [0] = 179;
        Horizontal[0] = 196;
    
        UpperLeft [1] = '\0';
        UpperRight[1] = '\0';
        LowerLeft [1] = '\0';
        LowerRight[1] = '\0';
        Vertical  [1] = '\0';
        Horizontal[1] = '\0';
    
    
        // CORNERS
        _settextposition(Row+4,Col);
        _outtext(UpperLeft);
        _settextposition(Row+4,Col+30);
        _outtext(UpperRight);
        _settextposition(Row+24,Col);
        _outtext(LowerLeft);
        _settextposition(Row+24,Col+30);
        _outtext(LowerRight);
    
        // Horizontal Lines
    
        for ( k = 0; k < 29; k++)
        {
            _settextposition(Width,12+k);
            _outtext(Horizontal);                                                  
    
            _settextposition(Width-20,12+k);
            _outtext(Horizontal);
    
        }
    
        //Vertical Lines
    
        for ( k = 0; k < 19; k++)
        {
            _settextposition(11+k,Height-9);
            _outtext(Vertical);
    
            _settextposition(11+k,Height+21);
            _outtext(Vertical);
    
        }
    
    }
    Attached Files Attached Files
    Last edited by hungrymouth; 11-18-2012 at 07:45 PM.

  2. #2
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    Can you post it using bb-tags?


    [code]
    Insert code here...
    [/code]


    A lot of people do not like downloading files.
    Fact - Beethoven wrote his first symphony in C

  3. #3
    Registered User hungrymouth's Avatar
    Join Date
    Oct 2012
    Posts
    19
    ok I did it hope it's better

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Go read my reply to you in <dream.in.code>

    You should NOT be using these hard coded "magic" numbers, and my answer there tells you how to set up your box, correctly.

    Code:
     _settextposition(Row+4,Col);
        _outtext(UpperLeft);
        _settextposition(Row+4,Col+30);
        _outtext(UpperRight);
        _settextposition(Row+24,Col);
        _outtext(LowerLeft);
        _settextposition(Row+24,Col+30);
        _outtext(LowerRight);
     
        // Horizontal Lines
     
        for ( k = 0; k < 29; k++)
        {
            _settextposition(Width,12+k);
            _outtext(Horizontal);                                                 
     
            _settextposition(Width-20,12+k);
            _outtext(Horizontal);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help : creating DLL in C
    By Somnium in forum C Programming
    Replies: 4
    Last Post: 12-09-2011, 03:32 PM
  2. Help with Creating a GUI
    By abujdan in forum C Programming
    Replies: 4
    Last Post: 04-06-2011, 08:36 AM
  3. Creating a map
    By DanFraser in forum C# Programming
    Replies: 7
    Last Post: 01-23-2009, 06:23 AM
  4. Creating a GUI in C
    By Mavix in forum C Programming
    Replies: 23
    Last Post: 05-03-2007, 10:19 PM
  5. Creating.......
    By incognito in forum Game Programming
    Replies: 3
    Last Post: 03-16-2003, 01:27 PM

Tags for this Thread