i need help with my comp sci hw:
here is the problem we have to solve(this is what the professor gave us. including the hint):
1. Write a program that prompts the user to enter a string containing a short English phrase with a single space between any two successive words. The program then outputs each word of the phrase separately. Test your program with the following input line “This is a test phrase” where the output for that input must be:
First word: This
Second word: is
Third word: a
Fourth word: test
Fifth word: phrase
Hint: You need to use various string manipulation functions.
this is what im trying to do:
#include
#include
using namespace std;
int main()
{
string inputstr;
cout << "Input Sentence= ";
getline(cin, inputstr);
int letter;
if letter==letter;
cout << letter;
if letter==' ';
cout << endl;
if letter=='\0';
cout << endl;
return 0;
}
he did not teach us about loops yet, do i dont think i can use those. i keep getting this error
2007-10-05
02:22:27
·
2 answers
·
asked by
Rock Lee
3