can someone give me a little help

This is a discussion on can someone give me a little help within the C++ Programming forums, part of the General Programming Boards category; I am really just starting to learn C++ and needless to say it is very challenging (which is something I ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    3

    Lightbulb can someone give me a little help

    I am really just starting to learn C++ and needless to say it is very challenging (which is something I enjoy) Anyhow enough about that. I have decided that the only way for me to really get a good understanding on how to write programs in C++ would be to start writing various programs for FUN[B] and have it applied to other things I enjoy doing. I am trying to figure out a way to write a program that will allow the user to input in what key (ABCDEFG) the user will be playing with. And depending on which key the user picks the program will output the Major scales,minor scales and locations on the frettboard.


    Ok I understand how to get the program to output what I need it to but I can't figure what to use so the program will read what the user has been inputted. Should I use a file with all the info on it and have the program read the file and output it to the user? Or is there another function that I can use. I don't think this is a very diffcult thing to write but I may be wrong .I am not asking anyone to write my program for me or nothing I am just asking what code I could use to have a program that will do this. If this doesnt really make sense if you reply I will try to clarify it more for you. Thanks

  2. #2
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    From what I understand, you want the user to input a letter (ABCDEFG) and then do something based on that. A simple way would be something like this:
    Code:
    bool goodKey(char key)
    {
        return (key == 'A' || key == 'B' || key == 'C' || key == 'D' || key == 'E' || key == 'F' || key == 'G');
    }
    
    ...
    
    char key;
    
    if (cin.get(key) && goodKey(key))
    {
        switch (key)
        {
        case 'A':
            // Do something
            break;
        case 'B':
            // Do something
            break;
        case 'C':
            // Do something
            break;
        case 'D':
            // Do something
            break;
        case 'E':
            // Do something
            break;
        case 'F':
            // Do something
            break;
        case 'G':
            // Do something
            break;
        }
    }
    p.s. What the alphabet would look like without q and r.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    73
    You could also do the above w/o using a seperate function:

    Code:
    main()
    {
      char input; //declare
      input = getch(); //get character....
      switch (input) //switch statement block
      {
         case 'A':
           //yeah...
           break;
        //and so on through all the letters from here
         default:
           cout<< "Invalid character";
       }
    }

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    3
    Wow thanks for the help guys !!!!!!!!! I am gonna try it out ASAP I will let ya know how it comes out.Thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Give me some opinions on setting up a server
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 04-19-2004, 10:38 AM
  2. Can you give me your tip plz :)
    By dionys in forum C Programming
    Replies: 6
    Last Post: 04-11-2004, 11:14 PM
  3. Can you give me an example of a new line character?
    By Golffor1 in forum C++ Programming
    Replies: 1
    Last Post: 04-10-2003, 11:59 AM
  4. How To Give A Font Colour ?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 09-14-2001, 01:22 PM
  5. Just to give you an idea of what we're going through...
    By rick barclay in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 09-13-2001, 02:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21