C - C++ Strings - Accessing characters in a string

#include <iostream>
#include <string>
#include <cctype>
using std::cout;
using std::cin;
using std::endl;
using std::string;
 
int main() 
{
  string text = "Forgetcode";
  char c;
  int numofvowels = 0;              
  int numofconsonants = 0;  
  int k=text.length();
 
  for(int i = 0 ; i < k ; i++)
    if(isalpha(text[i]))
      c=tolower(text[i]);
 
  switch(c) 
  {                   
    case 'a':
    case 'e':
    case 'i':
    case 'o': 
    case 'u':
      numofvowels++;
      break;
 
    default:
      numofconsonants++;
  }
 
  cout << "Given string: "<<text;
  cout<<"\nNumber of vowels:"<<numofvowels;
  cout <<"\nNumber of consonants:" << numofconsonants<<endl;
 
  return 0;
}