C programming project

Discussion in 'Web Design & Coding' started by FishBoy, Nov 2, 2004.

  1. hi i have to do some ascii buildings for a c programming projects it's all working great except that the windows go over the wall limit

    i attached the picture of the output. i want it to stop drawing the windows if the last windows will go over the limit, what is the equation to let it not overflow, i know how to code good but i dont know how to do all the math parts in the coding

    thanks guys
     

    Attached Files:

  2. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    count each character as you append it maybe, and create each line that way, if its over a certain value then drop the wall over it
     
  3. could you explain a little bit more please i kinda get what you mean but not really sure of what to do
     
  4. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    left_padding + number_of_windows*window_width + (number_of_windows - 1)*intermediate_padding + right_padding compared to wall_width perhaps?
     
  5. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    well it was something like having a basic counter controlling the whole thing and then you just append the character to the end of the string you are going to output. or you could do something where each time you append a new character to the string you check to see if the string is 1 less then the width of the house, if it is then you stick on the side wall and begin the next new line.

    alternatively you could create the string of output, then check its length and if its longer than the width of the wall then you chop it one before the max width and stick the piece of wall in