14.cpp
来自「这是一些c++例程」· C++ 代码 · 共 29 行
CPP
29 行
// 14.cpp : Defines the entry point for the console application.
// 演示数组的初始化
#include "stdafx.h"
#include <iostream>
using namespace std;
enum {array_size = 6};
void watch(const int *x)
{ // 遍历全部的数组元素
for (int i = 0; i < array_size; i++)
cout << " x[" << i << "] = " << x[i] ;
cout << endl;
}
void main()
{
int a[array_size] = {0};
int b[array_size] = {1};
int c[array_size] = {1,2,3};
int d[array_size];
//编译器可能将告警:数组未初始化
watch(a);
watch(b);
watch(c);
watch(d);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?