Quote:
Originally Posted by Kenny_Strawn
like that too many variables hog memory.
|
All variables require memory, don't worry about too many variables. Rather consider if the variable is required and where it is required. Local variables will be created (use up memory) when they come into scope (often when the function is called) and the memory that they use will be released when they go out of scope (you return from the function).
Often additional variables can simplify the code by (for example) keeping track of the state or by recording intermediate results.
Quote:
Originally Posted by Kenny_Strawn
What I want to know is how to assign a variable to the keyboard (in the C/C++ family) as such that the user has to type it in.
|
Others have given you some assistance here so I'll not add to it unless you require further help. However, if data is coming in from the keyboard you need to be careful and add error checking because the user my not enter what you expect, for example a user might type
ten rather than
10.