Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85719316
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
Tue, Oct 1, 15:51
Size
483 B
Mime Type
text/x-c
Expires
Thu, Oct 3, 15:51 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21251982
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