What is the mistake in following code?

This is a discussion on What is the mistake in following code? within the C Programming forums, part of the General Programming Boards category; Dear all, I am unable to rectify the error in following code:- Code: void Add_int(int, int); int main(int argc, char* ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    83

    What is the mistake in following code?

    Dear all,
    I am unable to rectify the error in following code:-

    Code:
    void Add_int(int, int);
    int main(int argc, char* argv[])
    {
    	int (*function)( int, int);
      int x, y;
      float a,b;
      printf("Enter two int values\n");
      scanf("%d %d", &a, &b);
      function=Add_int; 
    	return 0;
    }
    
    void Add_int(int x, int y)
    {
      int sum=0;
      printf("%d",sum);
    }
    Regards,
    Swetha

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    for floats use scanf("%f"..., instead of %d

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    also your function pointer has a different type from the function (return type of th efunction differs)

    and posting your compilation wanrings will help to receive answers
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. where is my mistake following this code..
    By transgalactic2 in forum C Programming
    Replies: 9
    Last Post: 10-18-2008, 01:44 PM
  2. where is my mistake in undersanding the order of this code..
    By transgalactic2 in forum C Programming
    Replies: 9
    Last Post: 10-08-2008, 08:26 AM
  3. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21