redundant variables

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2005
Posts: 2
Reputation: 3246251196 is an unknown quantity at this point 
Solved Threads: 0
3246251196 3246251196 is offline Offline
Newbie Poster

redundant variables

 
0
  #1
Jan 20th, 2005
take a look at this code:

---
void redundant_var()
{
char user_name[]="";
cout<<"insert name: "; cin>>user_name;
swap_name(user_name); //another function not seen
}
---

now, the following code works fine, but i am SURE there is a away to pass in user_name without the need of storing it in a temporary variable.

cannt you pass the CONSOLE_INPUT straight into the function?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,866
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: redundant variables

 
0
  #2
Jan 20th, 2005
>cannt you pass the CONSOLE_INPUT straight into the function?
Not the way you want to do it, no.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: redundant variables

 
0
  #3
Jan 20th, 2005
cin returns itself, not the thing(s) it reads from the input.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: redundant variables

 
0
  #4
Jan 20th, 2005
cannt you pass the CONSOLE_INPUT straight into the function?
Why do you WANT to do that.....?

If anything what is wrong with...
  1. function(cin.getline(...));

...will grab the input and pass it to the function.
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,866
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: redundant variables

 
0
  #5
Jan 20th, 2005
>...will grab the input and pass it to the function.
Be more specific or I'll have to describe in detail why you're wrong. Since you've proven yourself to know C++ fairly well, I'll give you the benefit of the doubt and assume that you just worded your post poorly.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 2
Reputation: 3246251196 is an unknown quantity at this point 
Solved Threads: 0
3246251196 3246251196 is offline Offline
Newbie Poster

Re: redundant variables

 
0
  #6
Jan 21st, 2005
Originally Posted by 1o0oBhP
Why do you WANT to do that.....?

If anything what is wrong with...
  1. function(cin.getline(...));

...will grab the input and pass it to the function.
ok thats excellent:

"swap_name(cin.getline());"

or does something have to go int the parenthesis (which i am confident does)
Reply With Quote Quick reply to this message  
Reply

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




Views: 1653 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC