Guest User

Untitled

a guest
Nov 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. int factorial(int);
  2. int main(void)
  3. {
  4. char x=5;
  5. printf("%d!=%d",x,factorial(x));
  6. return 0;
  7. }
  8.  
  9. int factorial(int n)
  10. {
  11. if (n==1)
  12. return (1);
  13. else
  14. return (n*factorial(n-1));
  15. }
  16.  
  17. char x=5;
  18. int n;
  19. n = x;
  20. //あるいは
  21. n = (int)x;
  22.  
  23. test.c: In function 'main':
  24. test.c:7:31: warning: passing argument 1 of 'factorial' makes integer from pointer without a cast [-Wint-conversion]
  25. printf("%d!=%d",x,factorial(&x));
  26. ^
  27. test.c:3:5: note: expected 'int' but argument is of type 'char *'
  28. int factorial(int);
  29. ^
Add Comment
Please, Sign In to add comment