Char Pointer Array cin Problem
Hello Guys,
I want to write a simple program about guitar scales!
I want to store scales in program like: A B C D E F G as a CMajor and so on..
And I'd like to input dynamic sized notes( like: C# D E or more ), and make program search for which scale could be belonging that notes. Waiting for one or more scales in return according my input size.
So this is what i done so far, my problem is at inputing notes and assigning to the array. By the way i am not a newbie but a noob, Thanks for the anwers!
Code:
#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[])
{
int s=0;
char *gam[3][8]; // This is for storing SCALES, This size for now.
char *sual[7]; // This is my input array for searching
char g[1]; // This cin my NOTE input and assigns it to sual[] array for further.
for(int i=0; i<3; i++)
for(int j=0; j<8; j++)
gam[i][j]="NULL";
for(int i=0; i<7; i++)
sual[i]="NULL";
// HERE I WROTE THE SCALES THERE ARE 2 FOR NOW
gam[1][0]="You're gam is C or Am";//the first slots for RETURN. To see which scale am i in.
gam[1][1]="C";
gam[1][2]="D";
gam[1][3]="E";
gam[1][4]="F";
gam[1][5]="G";
gam[1][6]="A";
gam[1][7]="B";
gam[2][0]="You're gam is D or Bm";
gam[2][1]="D";
gam[2][2]="E";
gam[2][3]="F#";
gam[2][4]="G";
gam[2][5]="A";
gam[2][6]="B";
gam[2][7]="C#";
cout << "Welcome SCALE FinDer!!..\n";
cout << "Please Enter you're Scale you want to search..." << endl; // I input the notes one by one
cin>>g;
sual[s]=g; // here is my intial problem WHY i cannot assign cin directly to sual[s].
while(s<6)// THIS is for maximum 7 notes are enough to determine.
{
s++;
cout<< " Enter the other note.. IF YOU HAD ENTERED LAST NOTE ENTER X "<<endl;
cin>>g;
if(g=="X")// THIS IF IS NOT WORKING, ALWAYS DOES THE ELSE STATE
break;
else
sual[s]=g;
}
//THS IS WHAT I DID SO FAR, AND IF I OUTPUT RESULTS.
cout<<sual[0]<<sual[1]<<sual[2]<<sual[3]<<sual[4]<<sual[5]<<sual[6]<<endl;// THE ALL 7 WILL BE WHICH NOTE ENTERED LAST.
return 1;
}