English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i assigned a certain value in a certain variable, i have a lot of variables to compare with the user's input, what function will i use? (i'm making the mastermind program using c)

2007-01-16 22:45:01 · 3 answers · asked by Sammy Baby 1 in Computers & Internet Programming & Design

i assigned a certain value for the variables and i have to compare them ALL to the input of the user, who has a mastermind source code in C...

2007-01-16 23:01:13 · update #1

3 answers

it depends.. what are you trying to achieve by your comparison? maybe you should compare what the memory that the variable points to contains if you are trying to find an exact match ... if you do do that remember to unallocate everything before assigning values in there also... but you can't do a broad sweep comparison, are you expecting string / char data or an integer or a float?? Need more detail for that one.

2007-01-16 22:50:08 · answer #1 · answered by JT 3 · 0 0

Instead use an array for those "a lot of variables to compare with "...meaning, store what is in those variables into a common array that way you can just use a for loop to compare them one at a time with your user input...in essense it could then be as small as 3 lines of code to compare them all and take an action.

2007-01-16 22:56:59 · answer #2 · answered by Anonymous · 0 0

Erm.. in c language u can use an Array to compare the variables all... but u need to know how many space or bit u need for the array to loop for.. instead of this u can use Linked-List which no need to know how many space u need.. it only need u to assign new item if u need the space for the next variables... Hope it help up..

2007-01-17 00:03:06 · answer #3 · answered by Onikids 2 · 0 0

fedest.com, questions and answers