C程序中的非法初始化 [英] Illegal Initialization In C Program

查看:44
本文介绍了C程序中的非法初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Turbo C中运行此代码,并在第9行进行了非法初始化我做错了什么???

I tried to run this code in the Turbo C and got illegal initialization at line 9 What did I do wrong???

#include<stdio.h>
#include<conio.h>

void main()
{

 int names[] = {23,23,34};

 int *nam[] = { names, names+1 , names +2};

 char *temp;

 clrscr();


 printf("%u" , (nam));

 getch();
}

推荐答案

您会遇到此问题,因为您的编译器已经过时了.在17年前废止的旧C标准中,除了编译时常量外,您无法使用其他任何方法初始化数组.

You get this problem because your compiler is hopelessly outdated. In an old C standard, which was withdrawn 17 years ago, you couldn't initialize arrays with anything but compile-time constants.

在1999年,出现了一个新的C标准,该标准修复了许多此类缺陷.为了编译此代码,您需要一个支持该语言的"C99"更新的编译器.

In 1999 there was a new C standard which fixed a lot of flaws like this. In order to compile this code, you need a compiler which supports the "C99" update of the language.

这篇关于C程序中的非法初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆