c++: Questions regarding strings and cases

Discuss all aspects of programming here.

Moderator: The Mod Squad

c++: Questions regarding strings and cases

Postby Finalcloud13 » Tue Oct 30, 2007 12:03 am

In my entry-level computer science course, the professor wants us to write a little program that will classify a message as spam or not. Some of the instructions that are giving me trouble are the following:

1. "Enter the body of the email. Press enter on an empty line to finish." I don't understand how to do this. To make myself clear here, I mean that the user has to press Enter on an empty line in order to finish writing the body part. Example:
//This is what I want, but don't have.
Hi mom. <-- the user is able to hit the Enter key on this line
<-- and again on this line to submit the body.

//This is what I have, but don't want.
Hi mom. <-- the user is only able to press Enter once before the program takes the input.


2. What do I do to check if a string has least one word, and more than 90% of the words in the subject line consist of only uppercase letters?

More questions to come soon :x Thanks in advance.
Finalcloud13
Pilgrim
Pilgrim
 
Posts: 14
Joined: Sat Jul 28, 2007 9:43 am

Postby dve83 » Sun Dec 02, 2007 4:08 am

this seems like a console application.
1.) try looking into the getline() function. then your can concatenate the results in the end.

2) the long way around would be to loop through the string character by character. Read the text into an array until you get to a 'space'. Afterwards check each array item for uppercase/lowercase (sorry cant remember string function names), and keep count of those that match the condition.

not sure how much detail you need. ask if you need any more help.
-dve83- Folding for 33258
Gigabyte GA-MA69VM-S2,AMD Athlon X2 5200+, 6GB DDR2-800, Seagate 250GB 7200 RPM, Western Digital 1TB 7200RPM,
460W Coolermaster PSU, Windows 7

"Perhaps it's not paranoia. Perhaps it's just finesse." - dve83
dve83
Black Belt
Black Belt
 
Posts: 615
Joined: Sun Jun 29, 2003 3:58 pm
Location: South Africa, Cape Town


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests