unsigned long long 就个什么东西?64位?有代码,有真相,请进
- C/C++ code
/*unsgn_pow.c */unsigned long long unsgn_pow(unsigned int x,unsigned int y){ unsigned long long res=1; if(y==0) { res=1; } else { if(y==1)a { res=x; } else { res=x*unsgn_pow(x,y-1); } } return res;}- C/C++ code
/*pow_test.c*/#include <stdio.h>#include <stdlib.h>int main(int argc,char *argv[]){ unsigned int x,y; unsigned long long res; if((argc<3)||(sscanf(argv[1],"%u",&x)!=1)||(sscanf(argv[2],"%u",&y)!=1)) { printf("Usage:pow base exponet\n "); exit(1); } res=unsgn_pow(x,y); printf("%u ^ %u= %u\n",x,y,res); exit(0);}目的就将unsgn_pow.c做成一个静态链接库,在UBUNTU 用GCC4.6.1进行编译,出现一下错误,是什么原因呢
root@jsj-virtual-machine:~/workspace# ar rcsv libpow.a unsgn_pow.o
r - unsgn_pow.o
root@jsj-virtual-machine:~/workspace# gcc -o pow_test pow_test.c -L. -lpow
pow_test.c: 在函数‘main’中:
pow_test.c:13:3: 警告: 格式 ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘long long unsigned int’ [-Wformat]
[解决办法]
应该是%llu
[解决办法]
%llu