By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,530 Members | 880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,530 IT Pros & Developers. It's quick & easy.

Cannot convert 'int**' to 'int*' for argument '1' to 'void shw(int*)' ?

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. void disp(int *n);
  3. void shw(int *k);
  4. main()
  5. {   int i;
  6.     int arr[7]={8,2,3,4,5,6,7};
  7.     for(i=0;i<=6;i++)
  8.     {
  9.         disp(&arr[i]);
  10.     }
  11. }
  12. void disp(int *n)
  13. {
  14.     shw(&n);
  15. }
  16. void shw(int **k)
  17. {
  18.     printf("%d",**k);
  19. }
Feb 1 '16 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
The function prototype is:

Expand|Select|Wrap|Line Numbers
  1. void shw(int *k);
so &n is an int**.

Never mind the function definition is:

Expand|Select|Wrap|Line Numbers
  1. void shw(int **k)
  2. { etc...
because that's some other function. Unless there's an error in the prototype...
Feb 1 '16 #2

Expert 100+
P: 2,398
Function shw appears three times:
  1. Line 3: function prototype.
  2. Line 14: function called.
  3. Line 16: function definition.
The function prototype is inconsistent with the rest; and also with how the function uses its argument on line 18.

I think the prototype is wrong.
Feb 1 '16 #3

Post your reply

Sign in to post your reply or Sign up for a free account.