I taught using books k and r. Interesting enough, but I ran into problems at an early stage, and I'm not sure how to solve the problem.
I am trying to execute a very simple code example and I am getting the following error. I donโt understand why, because the code is directly from the book.
main.c:11: warning: passing argument 2 of โsprintfโ makes pointer from integer without a cast
#include <stdio.h>
main() {
int i;
int power(int base, int n);
for (i = 0; i < 10; i++) {
sprintf("%d %d %d\n", i ,power(2, i), power(-3, i));
return 0;
}
}
int power(int base, int n) {
int i;
int p;
p = 1;
for (i = 1; i <= n; ++i)
p = p * base;
return p;
}
I would be grateful that I would go down the road again.
source
share