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?

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

cin returns itself, not the thing(s) it reads from the input.

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.

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

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.