This archived discussion is "read only" due to the absence of an active Feature Writer/moderator for this topic.
» Guy Lecky-Thompson - how to run a program?
In response to how to run a program? posted by chinxan87:Firstly, you need to decide how you are going to get the input from the user. The choices are : from the command line, or as input during the execution.
Then, you must construct a counted loop in which each cell to be drawn is visited by a step in the loop.
There are two ways to do this : either construct two loops, one for the vertical lines, and one for the horizontal lines (2 of each), or test each cell to see if it is on the border in a nested loop, and write to it if it is.
Clue : the first approach is easy, the second is harder, more computationally expensive, but has some benefits, I'm sure.
In pseudocode, you'll end up with something like:
FOR X = 0 TO SCREEN_WIDTH
PRINT USER_CHARACTER AT POS X, 0
PRINT USER_CHARACTER AT POS X, SCREEN_DEPTH
END FOR
FOR Y = 0 TO SCREEN_DEPTH
PRINT USER_CHARACTER AT POS 0, Y
PRINT USER_CHARACTER AT POS SCREEN_WIDTH, Y
END FOR
For a detailed discussion on loops in C, click here.
For a full C programming tutorial, covering every aspect of this language, click here.
Hope this helps, and look out for the fully worked out tutorial!
This archived discussion is "read only" due to the absence of an active Feature Writer/moderator for this topic.
Please follow the guidelines set forth in the Suite101 Posting Etiquette when adding to the discussion.