[Dev-C++] Re: Newbie: setting vars with for loop trouble.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ray K. <ray...@my...> - 2004-06-18 14:24:39
|
"Dane Ensign" wrote: > In the function I need to use a for loop to increment through my six > dice variables that I set as global variables as: > die1, ..., die6. I cant figure out how to append the value of my > for-loop variable to the name of my "die" variable, so I can set it? > Is there a better way to do this? Im not supposed to use an array for > this assignment, but I am supposed to use a loop. If this is for a homework assignment, shouldn't you be figuring out the solution on your own? I will give you a pointer: What you wish to do is called "string concatenation", and there is a function in the standard library that handles it. (Actually, there are two functions in the standard library that would work here. I leave finding them to you.) |