Few things on recent questions...

Hi guys,
Few things (mostly for Kristopher's benefit):
* Tyler is right: You cannot really use strings as part of the switch statement. It will accept integer types such as characters and ints (characters also, because it uses ASCII table). * Overall program flow (mostly for Kristopher): In my opinion, start with the output test first - to really make sure that output works as expected. Also, to help yourself with reading the output, I suggest putting a new line character (endl) at the end of your output code, like:
cout << "testing..." << endl;
If you are writing a text adventure or any kind of console program, I suggest using a collection of smaller functions to do the work for you. These functions can be put in as a header (h) file so that you can test your output code, input, then each of the functions in the header by the time you include this. This has advantages, including porting over to object-oriented approach (especially if you are planning to use a character or an object class to do some work), flexibility and cleaner code and so forth. As for overall thing on "goto," no info on that from my end (I'm just learning stuff as of now). * Conditionals: Tyler is right when saying that we do need else if statements. Sometimes, we don't need it, partiularly if we are comparing two different things or comparing two different actions. For instance, if you are writing a program to print out how many days are in a given month, you would use else if. However, if your program has two ejitionals, with one comparing a character vwithsus another comparing a string - that's when just using if becomes handy (a more advanced example would be inserting an item in a binary search tree, which I used a combination of if/else if and a series of if statements). * Program layout (again for Kristopher): As I said earlier, put some one-liner comments - to remind yourself what you are doing at that moment when the program is run. Also, try using small functions to help you. * Learning experience: I know that you are frustrated, but keep this in mind: we are speaking from experience learning about programming and investigating how the program would look like when a CPU encounters it. It is better to learn simple things, applying it and then moving onto more advanced materials. If I were you, I'd start out with learning about if statements, then switch, loops and onto functions. Right now I'm learning how to implement tables using C++ - binary search tree and chained hash table, which requires a lot of conditions and hours of formulating the algorithm before I even start writing it down in code. As always, if you have any questions, feel free to ask us - and I'm sure we'll try our best to help you, and in cases like this, give some advice.
Cheers,
Joseph
__________
View the list's information and change your settings at http://www.freelists.org/list/programmingblind

Other related posts: