Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122414183
ch-04-ex-02-solution.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 17, 18:16
Size
483 B
Mime Type
text/x-c
Expires
Sat, Jul 19, 18:16 (2 d)
Engine
blob
Format
Raw Data
Handle
27481631
Attached To
R9360 PCSC_git
ch-04-ex-02-solution.cpp
View Options
/*
* chapter-04-exercise-02.cpp
*
* Integer swap with pointers
*
* Created on: Sep 24, 2012
* Author: Radu Popescu <radu.popescu@epfl.ch>
*/
#include <iostream>
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
=
5
,
j
=
10
;
std
::
cout
<<
"i = "
<<
i
<<
" , j = "
<<
j
<<
std
::
endl
;
// Swap
int
*
p1
,
*
p2
;
p1
=
&
i
;
p2
=
&
j
;
*
p1
=
*
p1
+
*
p2
;
*
p2
=
*
p1
-
*
p2
;
*
p1
=
*
p1
-
*
p2
;
// Check
std
::
cout
<<
"i = "
<<
i
<<
" , j = "
<<
j
<<
std
::
endl
;
return
0
;
}
Event Timeline
Log In to Comment