![]() |
| | #1 |
| Registered User Join Date: Jun 2009
Posts: 2
| What should I pass into the function parameters: by this I mean do I pass say, *num1, or the address it points to, num1. I am confused. Please provide code examples. Thanks |
| greeneyehawk is offline | |
| | #2 |
| Guest Join Date: Aug 2001
Posts: 4,923
| Yes, the address. Code: void swap( int* a, int* b );
int main( void )
{
int
i,
j;
swap( &i, &j );
int
* p = &i,
* q = &j;
swap( p, q );
}
|
| Sebastiani is offline | |
| | #3 |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| It will probably be easier if you provide code examples. But I think Sebastiani might have nailed this one.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS |
| MK27 is offline | |
| | #4 |
| Registered User Join Date: Mar 2009 Location: Nebraska
Posts: 72
| I'm assuming you know how memory addresses work. I'm also assuming other people will post code for you. This is just how I learned how pointer operators work. * gets the value at an address & gets the address of a value That's it. They really aren't that complicated once you understand them
__________________ Super amazing game! |
| ITAmember is offline | |
| | #5 |
| Registered User Join Date: Jun 2009
Posts: 2
| Thank you so much, I got it. |
| greeneyehawk is offline | |
![]() |
| Tags |
| function, pointers, swap |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pointers | InvariantLoop | C Programming | 13 | 02-04-2005 09:32 AM |
| Problem with function pointers | vNvNation | C++ Programming | 4 | 06-13-2004 06:49 AM |
| Staticly Bound Member Function Pointers | Polymorphic OOP | C++ Programming | 29 | 11-28-2002 01:18 PM |
| Contest Results - May 27, 2002 | ygfperson | A Brief History of Cprogramming.com | 18 | 06-18-2002 01:27 PM |
| function pointers and member functions | thor | C++ Programming | 5 | 03-19-2002 04:22 PM |