| | |
redundant variables
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 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?
---
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?
If anything what is wrong with...
C++ Syntax (Toggle Plain Text)
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:
no www
no nonsense
coming soon to a pc near you! :cool:
>...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.
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
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by 1o0oBhP
Why do you WANT to do that.....?
If anything what is wrong with...
C++ Syntax (Toggle Plain Text)
function(cin.getline(...));
...will grab the input and pass it to the function.
"swap_name(cin.getline());"
or does something have to go int the parenthesis (which i am confident does)
![]() |
Similar Threads
- Problem with external variables in Actionscript 3 (Graphics and Multimedia)
- help with parrallel arrays (C++)
- Problem with variables in Windows shell script (Windows NT / 2000 / XP)
- How to develop a new program (C++)
Other Threads in the C++ Forum
- Previous Thread: I need your suggestions in learning Language
- Next Thread: Overloading matrix bracket operators
Views: 1653 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






