C语言 数组之无限循环
2016-01-25 18:56
357 查看
#include<stdio.h> #include<stdlib.h> #include<Windows.h> //定于数组的大小 #define N 10 void main(){ //某些场合,我们可能不是要遍历数组,而是重复的遍历这个数组,我偶然学到了这个方法 int a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int index = 0; while (1){ //确保数组不会越界 if (index>N - 1) { index = 0; //每一次循环来个换行 printf("\n"); Sleep(2000); } //做自己想实现的操作 printf("%5d",a[index]); index++; } system("pause"); }
相关文章推荐
- C++中可以接受任意多个参数的函数定义方法
- C语言 百炼成钢15
- 链表ADT C语言实现
- Face Alignment at 3000FPS(C++版)工程配置(非Cmake)
- C++中一个class类对象占用多少内字节
- c语言 setjmp和longjmp 实现协线程
- 解析C++编程中异常相关的堆栈展开和throw()异常规范
- C语言中内存分配 (转)
- C++编程异常处理中try和throw以及catch语句的用法
- C语言 segment fault
- 2009: C语言实验——各位数字之和排序
- C++智能指针的实现
- C++后台实践:古老的CGI与Web开发
- C++技巧之operator操作符
- 详解C++中new运算符和delete运算符的使用
- VC++获取当前系统时间日期 GetSystemTime()函数的用法
- 揭秘Facebook官方底层C++底层函数Folly
- C++读系统时间,且读出毫秒的方法[VC和GCC]
- IDEA算法c语言实现
- 揭秘Facebook官方底层C++底层函数Folly