Pls help me... in array problem..

Reply

Join Date: Jul 2008
Posts: 1
Reputation: xxReYMaXxx is an unknown quantity at this point 
Solved Threads: 0
xxReYMaXxx's Avatar
xxReYMaXxx xxReYMaXxx is offline Offline
Newbie Poster

Pls help me... in array problem..

 
0
  #1
Jul 26th, 2008
helow, can someone help me with my problem. my Teacher give me a problem, he want me to make an array that the output would be my name, buth with a space on it,

example:

Raymond

output:

R a y m o n d
&
R

a

y

m

o

n

d

using array,, pls help me i dont know how to start. im just new with this type of problem...
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Pls help me... in array problem..

 
0
  #2
Jul 26th, 2008
Write down on a piece of paper the steps, from start to finish to get the job done.

For example,

1) Prompt user for name;
2) Store name in char array/ std::string.
3) Get length of name...

etc
Last edited by iamthwee; Jul 26th, 2008 at 10:47 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: robertmacedonia is an unknown quantity at this point 
Solved Threads: 0
robertmacedonia robertmacedonia is offline Offline
Light Poster

Re: Pls help me... in array problem..

 
0
  #3
Jul 26th, 2008
I just got some kind of solution, I think it would work. Try this out, and please tell me if it does the job. Cause I'm a new guy too


[
  1. #include <iostream>
  2. using namespace std;
  3. void main ()
  4. {
  5. char name[30];
  6. cout<<"Enter a name ";
  7. cin.getline(name,30);
  8. for (int i = 0; i < strlen(name);i++)
  9. {
  10. cout<<name[i]<<endl;
  11. }
  12.  
  13. }
]
Last edited by Tekmaven; Jul 26th, 2008 at 2:15 pm. Reason: Code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Pls help me... in array problem..

 
0
  #4
Jul 26th, 2008
Originally Posted by robertmacedonia View Post
I just got some kind of solution, I think it would work. Try this out, and please tell me if it does the job. Cause I'm a new guy too

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void main ()
  6. {
  7. char name[30];
  8. cout << "Enter a name ";
  9. cin.getline ( name, 30 );
  10. for ( int i = 0; i < strlen ( name ); i++ )
  11. {
  12. cout << name[i] << endl;
  13. }
  14. }
>void main ()
That should be int main()

>for ( int i = 0; i < strlen ( name ); i++ )
It is expensive using strlen() within a for loop like that, I by that I don't mean $$.

It also doesn't help doing somebody else's homework.
Last edited by iamthwee; Jul 26th, 2008 at 11:19 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: robertmacedonia is an unknown quantity at this point 
Solved Threads: 0
robertmacedonia robertmacedonia is offline Offline
Light Poster

Re: Pls help me... in array problem..

 
0
  #5
Jul 26th, 2008
Man, I realise that you could solve the problem right away, I know you guys are experienced and these problems are too easy for you. I just wanted to help the dude like some of you guys helped me. And now that he's got the solution, he can look at it, and get new ideas and maybe surprise his teacher, who knows
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 401
Reputation: CoolGamer48 is on a distinguished road 
Solved Threads: 40
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Pro in Training

Re: Pls help me... in array problem..

 
0
  #6
Jul 26th, 2008
Originally Posted by robertmacedonia View Post
Man, I realise that you could solve the problem right away, I know you guys are experienced and these problems are too easy for you. I just wanted to help the dude like some of you guys helped me. And now that he's got the solution, he can look at it, and get new ideas and maybe surprise his teacher, who knows
Or he could submit it as his homework without giving it a second glance. By making him give us some code first or at least ask a specific question, we know that he's tried on his own first, and by only giving pieces of the answer, we know that he's doing some (and hopefully most) of the work.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: robertmacedonia is an unknown quantity at this point 
Solved Threads: 0
robertmacedonia robertmacedonia is offline Offline
Light Poster

Re: Pls help me... in array problem..

 
0
  #7
Jul 26th, 2008
OK, I won't do this again, I promise. And dude, try to understand the solution. it wasn't easy for me to write it, I'm a newbie you know.
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