0
void swap (int *first, int *second)
{
  int temp = *first;
  *first = *second;
  *second = temp;
}

int main ()
{
  int i = 5, j = 6;
  swap (i, j);
  printf ("i=%d j=%d\n", i, j);
}

warning:

[37] $ gcc -o ex321 ex321.c
ex321.c: In function `main':
ex321.c:14: warning: passing arg 1 of `swap' makes pointer from integer without a cast
ex321.c:14: warning: passing arg 2 of `swap' makes pointer from integer without a cast

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Samyx
0

Add -Wall option when you compile. (ignore!!_

Sorry another brain fart. You need to pass the address of the parameters to your swap function like so:

swap (&i, &j);

Edited by yellowSnow: n/a

0

Thank you!!! I also had forgot to return something in main().

Problem Resolved!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.