Guitar fretboard program help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Guitar fretboard program help

  1. #1
    Join Date
    Jun 2014

    Guitar fretboard program help

    So i have been wondering around the net and absorbing as much as possible about c++. I feel like i have a decent understanding of c++ but using what i have learned in a practical way is another story. I feel like the best way is just to start making a simple program. So i decided to make a name the note on the guitar fretboard and here is my code so far:

    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <ctime>
    using namespace std;

    int main(){
    char guitarNotes[7] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g' };
    char guitarStrings[5] = { 'e', 'g', 'b', 'd', 'f' };
    int note;
    int guitarNoteAr = rand() % 7;// Used to make the array guitarNotes random
    int guitarStringAr = rand() % 5;// Used to make array guitarString random

    string exit;
    cout << "This program will help you memorize the guitar fretboard.\n";

    cout << "Type Begin to start and Exit to quit. Good luck!" << endl;

    while (cin >> exit){
    if (exit == "Begin")
    cout << "Where is the " << guitarNotes[guitarNoteAr] << " note on the " << guitarStrings[guitarStringAr] << " string?" << endl;
    cin >> note;


    return 0;
    Having a bit of trouble as to how i should write the code to compare note.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Hanover Germany

    Re: Guitar fretboard program help

    Could you explain (in words!) what this program should do?

    And BTW, why does your guitar contain only 5 strings (neither 6, nor 7 nor 12)?
    Victor Nijegorodov

  3. #3
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012

    Re: Guitar fretboard program help

    When posting code, please use code tags. Go Advanced, select the code and click '#'.

    What is the user expected to reply in answer to the question? Say the question was

    Where is the b note on the f string?

    What would be the expected reply and why?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.6.6)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)