【发布时间】:2020-02-03 12:22:28
【问题描述】:
#include<iostream>
using namespace std;
struct student
{
char name [50];
int roll;
float marks;
}s = {"Karthik",1,95.3};
int main()
{
struct student s;
cout<<"\nDisplaying Information : "<<endl;
cout<<"Name : "<<s.name<<endl;
cout<<"Roll : "<<s.roll<<endl;
cout<<"Marks : "<<s.marks<<endl;
return 0;
}
输出:
Displaying Information :
Name :
Roll : 21939
Marks : 2.39768e-36
在 Visual-Studio-Code 上编译(在 linux 操作系统上) 我应该怎么做才能得到正确的输出。
【问题讨论】:
-
强制提醒
char name[50];不应在 C++ 中用作字符串。我们有std::strings。
标签: c++ visual-studio-code scope g++ global-namespace