这个程序能够成功编译,但是为什么无法执行??(自定义函数运行非法操作)
/*教科书上的题目是:
写一个函数 int mod(int x,int y),来计算并输出整数 x/y 的商数和余数.
以下是程序:
*/
#include<stdio.h>
#include<stdlib.h>
int mod(int,int);
int main(void)
{
system("CLS");
printf("Please Input Data X:");
int x,y;
scanf("%d",x);
printf("Please Input Data Y:");
scanf("%d",y);
mod(x,y);
system("PAUSE");
}
int mod(int x,int y)
{
float a,b;
a=x/y;
b=x%y;
printf("Data 1 Output is: %f",a);
printf("Data 2 output is: %f",b);
}
/*但是运行的结果出乎意料,一下子非法操作了,日志查看器中有以下记录:
事件类型: 错误
事件来源: Application Error
事件种类: (100)
事件 ID: 1000
日期: 2004-11-21
事件: 15:36:43
用户: N/A
计算机: SHAOJU-CHEN
描述:
错误应用程序 P156N04.exe,版本 0.0.0.0,错误模块 msvcrt.dll,版本 7.0.3790.0,错误地址 0x00031d50。
有关更多信息,请参阅在 http://go.microsoft.com/fwlink/events.asp 的帮助和支持中心。
数据:
0000: 41 70 70 6c 69 63 61 74 Applicat
0008: 69 6f 6e 20 46 61 69 6c ion Fail
0010: 75 72 65 20 20 50 31 35 ure P15
0018: 36 4e 30 34 2e 65 78 65 6N04.exe
0020: 20 30 2e 30 2e 30 2e 30 0.0.0.0
0028: 20 69 6e 20 6d 73 76 63 in msvc
0030: 72 74 2e 64 6c 6c 20 37 rt.dll 7
0038: 2e 30 2e 33 37 39 30 2e .0.3790.
0040: 30 20 61 74 20 6f 66 66 0 at off
0048: 73 65 74 20 30 30 30 33 set 0003
0050: 31 64 35 30 1d50
*/