I need help with my homework!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 4
Reputation: Latifa is an unknown quantity at this point 
Solved Threads: 0
Latifa Latifa is offline Offline
Newbie Poster

I need help with my homework!

 
0
  #1
Oct 16th, 2006
Hi,

I need help with my homework please, its due tommorow and i prommise to show my efforts in the next days

http://www2.filehost.to/files/2006-1...4316_cplus.jpg

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: I need help with my homework!

 
0
  #2
Oct 16th, 2006
Show your effort now, then we can help you with the next step.
http://www.daniweb.com/techtalkforum...cement8-2.html
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 4
Reputation: Latifa is an unknown quantity at this point 
Solved Threads: 0
Latifa Latifa is offline Offline
Newbie Poster

Re: I need help with my homework!

 
0
  #3
Oct 16th, 2006
I know that it means this:


below is a string of 20 chars
[01234567890123456789]

The first twelve are
[012345678901]

The last twelve are
[890123456789]

the middle 4 of the first string are shown marked with () below:
[0123(4567)08901]

the middle for of the last twelve are shown marked with () below:
[8901(2345)6789]
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: I need help with my homework!

 
0
  #4
Oct 16th, 2006
Yes, I've read your jpeg.

But what code have you managed to come up with so far?


For example, can you read the string from the user, and just print it back to the user?
Can you add to that printing the length of the string?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 4
Reputation: Latifa is an unknown quantity at this point 
Solved Threads: 0
Latifa Latifa is offline Offline
Newbie Poster

Re: I need help with my homework!

 
0
  #5
Oct 16th, 2006
I got till here,
#include <iostream>
#include <string>

using namespace std;



int main ()
{

string name;
cout<< "Enter name";
cin>> name;
Last edited by Latifa; Oct 16th, 2006 at 5:59 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: I need help with my homework!

 
0
  #6
Oct 16th, 2006
Maybe this will kick-start you
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main ( ) {
  5. string s = "hello world";
  6. cout << "The length is " << s.length() << endl;
  7. cout << "The 5th character is " << s[4] << endl;
  8. return 0;
  9. }

There are all sorts of different methods for manipulating strings.
http://www.sgi.com/tech/stl/basic_string.html
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 4
Reputation: Latifa is an unknown quantity at this point 
Solved Threads: 0
Latifa Latifa is offline Offline
Newbie Poster

Re: I need help with my homework!

 
0
  #7
Oct 17th, 2006
There must be a cin
#include <iostream>
#include <string>
using namespace std;
int main ( ) {
string = name;
cin >> name;
cout << "The length is " << s.length() << endl;
cout << "The 5th character is " << s[4] << endl;


return 0;
}
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1
Reputation: jdarvwill is an unknown quantity at this point 
Solved Threads: 0
jdarvwill jdarvwill is offline Offline
Newbie Poster

Re: I need help with my homework!

 
0
  #8
Oct 17th, 2006
to define a string variable,
  1. string s;
then read in,
  1. cin >> s;
then using the string stl use the necessary functions.

in particular look at, s.length(), s.substr()
the rest is trivial once you know how to use these functions.
Last edited by jdarvwill; Oct 17th, 2006 at 12:06 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC