RuneStorm
http://www.runestorm.com/forums/

Any C++ Programmers out there?
http://www.runestorm.com/forums/viewtopic.php?f=6&t=73111
Page 1 of 1

Author:  Captain Xavious [ Tue May 05, 2009 9:39 am ]
Post subject:  Any C++ Programmers out there?

I need to make a program that involves asking for a User ID from an array, checking to see if its valid, then asking for a Password from an array.

Unfortunately, I don't know how to work with arrays in C++... At all.

Anyone out there think they could help me out a bit?

Author:  Bjossi [ Tue May 05, 2009 10:44 am ]
Post subject:  Any C++ Programmers out there?

The basic definition is rather simple.

type name [index] = {content}
Example:
int numbers [3] = {1, 4, 8, 16}

You can also leave the index brackets empty if you want the compiler to decide the max index based on how many values you put into the curly brackets.


In the context of this particular assignment, you want to first ask the user to type a user ID and then make the program run a 'for' loop that "scans" the array for a match. Then you simply do the same thing for passwords (though if each user ID has a unique set of passwords, things get a little more complicated).

Author:  Captain Xavious [ Tue May 05, 2009 10:59 am ]
Post subject:  Any C++ Programmers out there?

Thanks!

Author:  DK [ Tue May 05, 2009 11:24 am ]
Post subject:  Any C++ Programmers out there?

Bjossi wrote:
type name [index] = {content}
Example:
int numbers [4] = {1, 4, 8, 16}


Fix'd, because even though the count is from 0-3, the number inside the braces represent the number of rows in the given array.

If you can manage it, you can also opt for a two-dimentional array, given that each User ID has a corresponding password.

int UIDandPass [i] [2] = {{UID1, UID2, UID3, UID4, ... UIDi-1}, {PASS1, PASS2, PASS3, PASS4, ... PASSi-1}}

The 1st number in braces will be for the length of the array and the 2nd for the depth. This saves a bit of coding work on the looping statement for scanning the array.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/