本人
#include <iostream>
using namespace std;
struct NoCutterspace
{
double NoWidth;
double NoPolar;
double NoAngle;
}no[]={
{1,2,1},
{2,4,6},
{6,6,8},
{4,5,6}
};
printfPolar()
{
int NoNum=sizeof (no)/(sizeof (double)*3);
cout<<no[NoNum-1].NoPolar<<endl;
}
int main()
{
printfPolar();
return 0;
}
上面的在main外赋值结构体数组可以,但是本人希望在main里面赋值结构体数组,并且在自定义函数printfPolar里对这个要输入的数组进行一些操作,在main函数里赋值就会报错,这样就不行了:
#include <iostream>
using namespace std;
struct NoCutterspace
{
double NoWidth;
double NoPolar;
double NoAngle;
}no[];
void printfPolar()
{
struct NoCutterspace no[];
int NoNum=sizeof (no)/(sizeof (double)*3);
cout<<no[NoNum-1].NoPolar<<endl;
}
int main()
{
NoCutterspace no[]={
{1,2,1},
{2,4,6},
{6,6,8},
{4,5,6}
};
printfPolar();
return 0;
}
讨教大家,上面程序怎么改呢
解决方案
40
本人的错,没把名字修正过来
你把printfPolar里面的no改为p