[Error] 'for' loop initial declarations are only allowed in C99 or C11 mode

#include <stdio.h>
#include <stdlib.h>
#define LIST_INIT_SIZE 100 //线性表存储空间的初始分配量
#define LISTINCREMENT 10   //线性表存储空间的分配增量(当存储空间不够时要用到)
typedef int ElemType;      //数据元素的类型,假设是int型的
typedef struct {
	ElemType *elem;       //存储空间的基地址
	int length;      //当前线性表的长度
	int listsize;    //当前分配的存储容量
} SqList;
int main() {
	SqList list;
	InitList(list);

	int n = 10;

	//添加10个数字给线性表list
	for (int i = 0; i < 10; i++) {
		ListInsert(list, i+1, i+1);
	}
	//删除第5个
	ElemType e;
	ListDelete(list, 5, e);
	printf("删除的元素是:%d
", e);

	//在第2个位置插入一个元素-1
	ListInsert(list, 2, -1);

	//输出线性表
	for ( i = 0; i < 10; i++) {
		printf("%d ", list.elem[i]);
	}
	//输出结果是:1 -1 2 3 4 6 7 8 9 10

	system("pause");
}

  

原文地址:https://www.cnblogs.com/rsapaper/p/10290662.html