![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Feb 2007
Posts: 2
Rep Power: 0
![]() |
How do I swap pointers with a function?
I need help with the following problem about swapping pointers.
The following code is in main: main()
{
int x=1,y=2;
int *xp,*yp;
.
.
.
xp = &x;
yp = &y;
intpswap(<arg1>,<arg2>);
x=3;y=4;
printf("*xp = %d, *yp = %d\n",*xp,*yp);
}and thus printf prints "*xp = 4, *yp =3". I know how to swap int values by using a temp variable, but is it the same approach here? Any help or hints will be greatly appreciated!! Thank you!! Last edited by Thiengineer; Feb 4th, 2007 at 7:09 PM. |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Confusion With Pointers and Arrays | JawaKing00 | C | 10 | Sep 14th, 2006 8:33 AM |
| Functions returing a pointer using new | Jessehk | C++ | 29 | Dec 21st, 2005 3:52 AM |
| pointers are difficult | cjaime | C | 3 | Nov 12th, 2005 1:26 AM |
| Pointers in C (Part II) | Stack Overflow | C | 2 | Apr 29th, 2005 11:39 AM |
| Pointers in C (Part I) | Stack Overflow | C | 4 | Apr 28th, 2005 8:03 PM |