oops ! code crashing.. :(
yup.. Im making a new exercise from a book im reading to learn c++
but what i did cant be good cause evry time i run it the program bugs.. (not computer tho..)
here it is:
Code:
void program()
{
int i;
char juju[20];
typedef pair<char,char> twin;
twin bob;
vector<twin> here;
here.push_back(bob);
cout<<"Enter a string of maximum 15 characters."<<endl;
cin>>juju;
for (i=0;i<10;i++)
{
here[i]=make_pair(juju[i],juju[i+1]);
}
for (i=0;i<19;i++)
{
cout <<i<<" " <<here[i].first<< here[i].second <<"\n";
}
}
what I've been asked to do (in book) is:
Quote:
Write a function that counts the number of occurences of a pair of letter in a string and another that does the same in zero-terminated array of char (a C-style string). For example, the pair "AB" appears twice in "XABAACBAXABB".
So i used vector so it will grow to fit the lenght of th string(right?) and pair holds 2 char which I will compare (eventually) with each other so this way I will know there is a matching pair..
so what is wrong?
vector doesnt grow all by itself maybe?
thx in advance..
Luigi