【发布时间】:2014-03-01 08:04:56
【问题描述】:
我需要分配一个包含 6 个数组的数组,它来自 set[maxSetLength] 类型
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#define maxSetLength 129
typedef short int set[maxSetLength];
int _tmain(int argc, _TCHAR* argv[]){
int i;
set a={0},b={0},c={0},d={0},e={0},f={0}; // Assigning 6 Sets (Arrays) initialized by zeros
set sets[6]={a,b,c,d,e,f}; //Inserting All Sets into one Array (Array Of Arrays)
}
在 CodeBlocks 中它编译没有错误,在 VS2010 中它没有,这些是错误:
6次
error C2440: 'initializing' : cannot convert from 'set' to 'short'
6 次
IntelliSense: a value of type "short *" cannot be used to initialize an entity of type "short"
总共有 12 个错误
【问题讨论】:
-
test.c:1:1: error: stdafx.h: No such file or directory。如果您要提出与 Windows 无关的问题,请在发布之前从您的代码中删除所有 Windows 主义。 -
@Zack 你是什么意思 Windowssisms ?老师是这样教我的
-
那你的老师不称职。
-
@Zack:他的老师不称职,因为他们在使用VS?克服自己。 VS 默认为许多项目类型添加了预编译的头文件,yeesh。不要再添加无用的 cmets 来吓唬初学者了。
-
无论如何,实际的严肃建议:下载 MSVC 2012 并尝试一下。我怀疑您正在尝试使用 CodeBlocks 实现而 MSVC 2010(较旧)没有实现的 C++11 功能。
标签: c arrays initialization