• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

C programming project

#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
 

Attachments

#2
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
 
#4
left_padding + number_of_windows*window_width + (number_of_windows - 1)*intermediate_padding + right_padding compared to wall_width perhaps?
 
#5
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
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,240
Members
89,015
Latest member
loxioalix