cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
how can this function swap value of x to
how can this function swap value of x to y or y to x
Nov 3, 2014 at 8:09pm UTC
xxgixxx
(41)
Question is the title
1
2
3
4
5
6
7
void
badswap (
int
x ,
int
y) {
int
temp = x; x=y; y=temp; }
Last edited on
Nov 3, 2014 at 8:10pm UTC
Nov 3, 2014 at 8:20pm UTC
closed account (
SECMoG1T
)
That is what will happens when you call it in a program
Nov 3, 2014 at 8:24pm UTC
Ispil
(788)
You want them to be passed by reference, not by value.
http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/
Topic archived. No new replies allowed.