Thread: Is this correct

  1. #1
    Registered User
    Join Date
    Feb 2002

    Is this correct

    #include <stdio.h>
    int main()
    int c=10, d=20;
    void swap(int *c, int *d);
    void change(int *c, int *d);

    printf("Before swap c=%d , d=%d ,", c,d);
    printf("After swap c=%d , d=%d ,", c,d);

    void swap(int *c, int *d)

    void change(int *c, int *d)
    int t;

    I am getting a compilation error

    kan1usp4.c:19: warning: type mismatch with previous implicit declaration
    kan1usp4.c:15: warning: previous implicit declaration of `change'
    kan1usp4.c:19: warning: `change' was previously implicitly declared to return `
    kan1usp4.c: In function `change':
    kan1usp4.c:21: invalid type argument of `unary *'
    kan1usp4.c:22: invalid type argument of `unary *'

    On the face of it the program looks fine. But, then why is the compilation error.


  2. #2
    Registered User
    Join Date
    Feb 2002
    U r correct. Thanks for ur reply.


  3. #3
    Join Date
    Sep 2001

    hmm.... Just try this.

    #include "stdio.h"
    void swap(int *a, int *b)
    	int temp;
    	// swap the values
    	temp = *a;
    	*a =   *b;
    	*b = temp;
    int main()
    	int x = 5, k = 10, temp;
    	printf("\n Before swap() : 'x' = %d , and 'k' = %d", x, k);
    	swap(&x, &k); // Swap the values of variables 'x', and 'k'
    	printf("\n After  swap() : 'x' = %d, and 'k' = %d", x, k);
    	return 0;
    Try not to use something like -> int **c, just use one * ( *c) ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux for GNU/Linux is not correct?
    By password636 in forum Linux Programming
    Replies: 8
    Last Post: 03-31-2009, 08:30 PM
  2. Is this correct : passing strings?
    By socket in forum C Programming
    Replies: 15
    Last Post: 11-25-2008, 02:03 PM
  3. correct order to insert new node?
    By campermama in forum C++ Programming
    Replies: 1
    Last Post: 06-16-2004, 07:51 PM
  4. Replies: 1
    Last Post: 05-26-2004, 12:58 AM
  5. Loop until enter correct value
    By jchanwh in forum C Programming
    Replies: 2
    Last Post: 11-27-2001, 01:23 AM