#include <stdio.h>
#include <math.h>void main( int argc, char *argv[] )
{
int x,y
div_t div_resultprintf("input x y:")
scanf("%d%d",&x,&y)
printf( "x is %d, y is %d\n", x, y )
div_result = div( x, y )
printf( "The quotient is %d, and the remainder is %d\n",
div_result.quot, div_result.rem )//x/y的商和余数
}
在stdlib.h头文件里面div的原型是inline ldiv_t div(__in long _A1, __in long _A2)
{
return ldiv(_A1, _A2)
}
返回值是 Idiv_t
应该是两个long的结构体啊,怎么能赋值给int呢,就是这里错了
typedef struct _ldiv_t {
long quot
long rem
} ldiv_t
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)