this game is called "pig latin" it spit all the string, put the first consonant to the end and adds "AY" to the end. for example --> "this is test" --->"histAY isAY estAY". it gives me string subscript out of range. thanks
#include <iostream>
#include "conio.h"
#include <string>
#include <sstream>
using namespace std;
int main(){
string sentence,temp;
int index;
int a,i=0,sayac=0;
string harf;
cout<<"enter the sentence"<<sentence <<endl;
getline(cin,sentence);
cin.clear();
cout<<"\nlenght: "<<sentence.length()<<endl;
temp=sentence;
for( i=0; i<sentence.length();i++)
if(temp[i]==' '){
sayac++;
temp[i]='**';
}
cout << "\n word count: " <<sayac+1<<endl;
//split
istringstream iss(sentence);
while(iss){
{
string sub;
iss >> sub;
cout << sub << endl;
a=sub.length();
index=sub.find_first_not_of("aeuio");
cout << "first consonant:"<< sub[index]<<endl;
harf=sub[index];
sub.insert ( a, harf ) ;
sub.insert (a+1, "AY");
sub.erase(index,1);
cout << "new word:" << sub << endl;
}
//split son
getch();
return 0;
}