11、输入一个正整数,然后创建一个动态的int数组,其中包含的元素个数等于用户输入的值
cin>>size;
int p[]=new int[size];
12、下面的代码是否有效?如果有效,它将打印出什么结果?
cout<<(int *)"Home of the jolly bytes";
运行结果:
0040564C
13、编写一段代码,给问题6中描述的结构动态分配内存,然后读取该结构的成员的值。
问题6:设计一个描述鱼的结构声明。结构中应当包括品种、重量、长度。
#include <iostream>
using namespace std;
struct fish
{
char kind[20];
int weight;
int length;
};
int main()
{
fish *ps = new fish;
cout<<"Input kind of the fish:";
cin>>ps->kind;
cout<<ps->name<<endl;
}