#include<iostream>
using namespace std;
void split(float x, int *intpart, float *floatpart)
{
*intpart = (int)x;
*floatpart = x - *intpart;
}
int main()
{
int i;
float x, j;
cin >> x;
split(x, &i, &j);
cout << "The intpart = " << i << endl;
cout << "The floatpart = " << j << endl;
system("pause");
return 0;
}
第五行的(int)x是个具体数值啊,为什么可以赋值给指针,可以赋值给指针的不只能是地址么?
using namespace std;
void split(float x, int *intpart, float *floatpart)
{
*intpart = (int)x;
*floatpart = x - *intpart;
}
int main()
{
int i;
float x, j;
cin >> x;
split(x, &i, &j);
cout << "The intpart = " << i << endl;
cout << "The floatpart = " << j << endl;
system("pause");
return 0;
}
第五行的(int)x是个具体数值啊,为什么可以赋值给指针,可以赋值给指针的不只能是地址么?