Matthew
2011-02-16 11:57:40 UTC
#include
#include
using namespace std;
void main()
{
string sentence;
char string1[]="";
char space[]=" ";
char period[]=".";
char word1[]=" ";
char word2[]=" ";
bool x=true;
cout << "This program turns a given sentence into a list of words." << endl;
cout << "Input a sentence: ";
getline(cin, sentence);
cout << endl;
int len = sentence.length();
for(int b=0; b
string1[b]=sentence[b];
}
int i;
int t;
for(i=0; i
if(string1[i]==space[0] || string1[i]==period[0])
{
for(t=0; t=i; t++)
{
word1[t]=string1[t];
}
break;
}
}
i=i+2;
int t1=t+2;
int b=0;
for(i; i
if(string1[i]==space[0] || string1[i]==period[0])
{
for(t1; t1 {
b=0;
word2[b]=string1[t1];
b=b+1;
}
break;
}
}
cout << endl;
cout << "The sentence as a list is: " << endl;
for(int f=0; f=t1; f++)
{
cout << word1[f];
}
cout << endl;
for(int f=0; f=b; f++)
{
cout << word1[b];
}
int endProg=0;
while(endProg==0)
{
cout << "To end the program type 1: ";
cin >> endProg;
cout << endl;
}
}