程序如下:为何编译出现错误提示:error C2552: 'stu' : non-aggregates cannot be initialized with initializer list。请高手指点。
#include
#include
using namespace std;
struct Student
{
int num;
string name;
float score[3];
}stu={12345,"lifeng",80,90,100};
int main()
{
void print(Student *);
Student *pt=&stu;
print(pt);
return 0;
}
void print(Student *p)
{
cout<num<<" "<name<<" "<score[0]<<" "<score[1]<<" "<score[2]<}
inet_addr的参数,就是一个char *。如果你的工程是多字节模式(非unicode),可以这样用,只需要去掉格式化字符串中的双引号就可以了。
cstring.format("%u.%u.%u.%u", nfield0,nfield1, nfield2, nfield3);
s_addr = inet_addr(cstring.getbuffer(0));