0

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?

4
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by 3246251196
0

>cannt you pass the CONSOLE_INPUT straight into the function?
Not the way you want to do it, no.

0

cannt you pass the CONSOLE_INPUT straight into the function?

Why do you WANT to do that.....?

If anything what is wrong with...

function(cin.getline(...));

...will grab the input and pass it to the function.

0

>...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.

0

Why do you WANT to do that.....?

If anything what is wrong with...

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)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.