Hi.
Why is it that the program doesn't stop for me to see the output?
Here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// accessing mapped values
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main ()
{
char str[] = "This table is a good table, while this book is a good book.There is an umbrella on the tablle";
int n = strlen( str );
char **token = new char*[n];
int i = 0;
for( ;i<n;++i)
token[i] = new char[n];
std::map<std::string, int> mymap;
i=0;
token[i] = strtok(str , " .,");
while(token [i])
{
token[++i] = strtok(0 , " .,");
mymap[token[i]];
}
std::cout << "mymap now contains " << mymap.size() << " elements.\n";
for(i = 0;i<n;++i )
cout << token[i] << endl;
while(1);
return 0;
}
|
?Thanks in advance
Last edited on