Computing.Net > Forums > Programming > VC++ Newbie problem

VC++ Newbie problem

Reply to Message Icon

Original Message
Name: Tugg
Date: February 18, 2003 at 22:56:43 Pacific
Subject: VC++ Newbie problem
OS: Win98\WinXP
CPU/Ram: 800MHz\256SDRam
Comment:

Ok. First of all thanks alot for everything, I did advance alot with the program. Now I know I said i did not want to be handed any code, but it looks like I will need a coded sample of something similar to what I explained before.

(For everyone that did not read my last post:
I need to compare a string value inputed from the user using strcmp to find the appropriate value in the first of two multidimensional arrays. Than the row/colum value needs to be passed to the second array to get the necessary information. Something like this:
string currency[][20] = {{"USD","HKD}{"USD","HKD"}};
double conversion[][20] = {{1,5}{1,5}};)

I just cant figure out the proper syntax for the look-up routine (tried for over one week).
So in other words: please give me some sample code (from anything) using strcmp with an array.
Thanks alot again.



Report Offensive Message For Removal

Response Number 1
Name: borelli34
Date: February 19, 2003 at 00:32:36 Pacific
Subject: VC++ Newbie problem
Reply: (edit)

tugg,

I'm not sure this is clear to me. Are you wanting to compare the contents of the two arrays or compare input from a user to either of the two arrays?

borelli34


Report Offensive Follow Up For Removal

Response Number 2
Name: Tugg
Date: February 19, 2003 at 02:39:31 Pacific
Subject: VC++ Newbie problem
Reply: (edit)

Sorry if this wasnt clear. I need to compare a user input to the currency array. So when someone types USD to start with and HKD to convert to, than the input is compared to the currency array until the value is found. Than the row/colum number (index numbers?) need to be passed to the conversion array which is organized in exactly the same way so that the right exchange rate is found.

Now I was told its best done using strcomp, but im not sure how to write the proper syntax with strcmp.
Hope this makes more sense
thanks


Report Offensive Follow Up For Removal

Response Number 3
Name: Ronin1
Date: February 20, 2003 at 20:22:46 Pacific
Subject: VC++ Newbie problem
Reply: (edit)

const char convert[MAXCONVERT] = { "US", "UK", "HK", "Whatever" };

for(int i=0; i MAXCONVERT; i++)
{
if((stricmp(userentry, convert[i])) == 0)
// match found... do what you need
}



Report Offensive Follow Up For Removal

Response Number 4
Name: Tugg
Date: February 23, 2003 at 18:10:26 Pacific
Subject: VC++ Newbie problem
Reply: (edit)

Thanks for the help. I did however have to use a 2 dimensional array to allow the user to start and end with any currency. Now the last problem is that i dont know the command for retrieving the row/col number of the array(still have to pass these values to the second array to find the exchange rate). Anyone know a good (pure!)reference book that I can buy for future problems? isbn?
Thanks


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: VC++ Newbie problem

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software