创建数组有三种方法

1、声明一个数组,声明时用常量表达式指定数组维数,然后可以用数组名访问数组元素

2、声明一个变长数组,声明时用变量表达式指定数组的维数,C99支持

3、声明一个指针,调用malloc(),然后使用该指针来访问数组元素,指针为常量,不能进行运算

#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
int *p;
p = (int *)malloc(n*sizeof(int));
if(scanf("%d",&n) != ){
printf("%s","exit");
exit(EXIT_FAILURE);
} int i; for(i=;i<n;i++){
printf("%d:",i);
scanf("%d",p+i);
} for(i=;i<n;i++){
printf("%d",p[i]);
}
}

最新文章

  1. 不使用return false阻止event默认行为
  2. 从零自学Hadoop(17):Hive数据导入导出,集群数据迁移下
  3. online_jf.lua --累计在线时间领取物品(积分)的lua脚本
  4. WPF控件
  5. [转]SQL注入攻防入门详解
  6. POJ 3111
  7. 关于dialog引起的 java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView not attached to window manager 错误的分析
  8. android Uri获取真实路径转换成File的方法
  9. SQL Server 阻塞排除的 2 方法
  10. 1.SQL统计某张表的列数。
  11. 前端学习笔记(zepto或jquery)——对li标签的相关操作(五)
  12. hdu_5877_Weak Pair(离散+DFS+树状数组)
  13. 在Windows上安装MongoDB
  14. [NOIp 2013]货车运输
  15. shell中read使用
  16. Lambda的使用与实战
  17. DensePose: Dense Human Pose Estimation In The Wild(理解)
  18. Codeforces 1009G Allowed Letters 最大流转最小割 sosdp
  19. 接口测试工具-poster
  20. python 各种开源库

热门文章

  1. 改变Android ProgressBar样式颜色
  2. 获取设备IMEI ,手机名称,系统SDK版本号,系统版本号
  3. iOS 开发之路(登陆验证调用WebService)二
  4. 打印frame
  5. TCP连接状态与2MSL等待时间
  6. Java基础知识学习(一)
  7. 表格table嵌套,边框合并问题
  8. Ubuntu 14.04 软件源服务器列表
  9. mysql metadata lock(一)
  10. C语言(函数)学习之strstr strcasestr