using switch statement help

here is my code. Here is a quick review of what i need to do: open a file of a list of numbers and get the first number and tally it for that number. Ex. number is 4563 it tallys 1 for number 4. And 2983 it tallys 1 for number 2. and loops through whole list and tallys numbers 1 - 9 and records them in the output. This outputs what i say but it outputs 0's for 1-9 instead of how many times it found a number that started with 1 and etc through 9. What it is doing is it outputs 0's for the 1 - 9 instead of what it was supposed to loop and find how many times 1-9 is used. Is it something with my num11 being set. If so could someone help me out.

int main ()
{

ifstream inFile;
int number, num1=0, num2=0, num3=0, num4=0, num5=0, num6=0, num7=0, num8=0, num9=0;
string num11;
int totals[10]={};
inFile >> num11;

cout << "Enter 1 for librarybooks or Enter 2 for livejournal : ";
cin >> number;



if ( number == 1 )
{
inFile.open("librarybooks-1.txt");
}

else if ( number == 2 )
{
inFile.open("livejournal-1.txt");
}

else
cout << "\n" << "Invalid number" << "\n" << endl;

switch(++totals[num11[0]-'0') // switch statement. Shorter code instead of writing each case

for (int i=1; i < 10; ++i)
{
cout << "Number of " << i << "s : " << totals[i] << endl; // the tallied numbers
}



return 0;
}
Topic archived. No new replies allowed.