C++ (String Input)

35 pts.
Tags:
C++
Input
String
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:
?

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Homework questions are not supported here. Sorry.
    68,710 pointsBadges:
    report
  • Bornwinner
    excuse me? This is not a homework question!
    35 pointsBadges:
    report
  • carlosdl
    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.
    68,710 pointsBadges:
    report
  • Bornwinner
    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 pointsBadges:
    report
  • Bornwinner
    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 pointsBadges:
    report
  • carlosdl
    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.
    68,710 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following