35 pts.
 C++ (String Input)
Hi , 
 How can we input a string without specifying its length before ? As in , the program should understand that the string has ended when the return key has ended.
The input string can be a line , word , blog , novel[It can be that big I mean to say]
Apart from that how to count the number of words , vowels and other things in the string.Please help me ASAP!


Software/Hardware used:
?
ASKED: March 7, 2010  12:41 PM
UPDATED: March 8, 2010  5:57 PM

Answer Wiki:
Here are some hints: -You will need to use pointers -You will need to use the new and delete operators. -You will probably need to use the strlen function -You will probably need to use the getche() function or similar. -The ascii code for ENTER is 13 -You will probably need to use loops to count words, vowels, etc.
Last Wiki Answer Submitted:  May 19, 2013  6:39 pm  by  Chris Leonard   2,600 pts.
All Answer Wiki Contributors:  Chris Leonard   2,600 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Homework questions are not supported here. Sorry.

 63,535 pts.

 

excuse me? This is not a homework question!

 35 pts.

 

Well, it looks like one. Specially this part:

As in , the program should understand that the string has ended when the return key has ended

Here are some hints:

-You will need to use pointers
-You will need to use the new and delete operators.
-You will probably need to use the strlen function
-You will probably need to use the getche() function or similar.
-The ascii code for ENTER is 13
-You will probably need to use loops to count words, vowels, etc.

 63,535 pts.

 

h>
#include <string.h>
#include <conio.h>
using namespace std;

int main ()
{
int a=0;
string str;
cout << “Enter string (EOL = $) : “;
getline (cin, str, ‘$’);
cout << “Str is : ” << str << endl;
}

See m using this , but how should I count the number of words in str.

 35 pts.

 

just tell me how to enter a string of unknown length !! and how to use it further..don’t tell me how to count vowels and everything .

 35 pts.

 

If you are using the string class, you should not worry about the string length, as you don’t have to declare its length beforehand.

If you were using pointers to chars, then the string length would matter.

 63,535 pts.