“{”令牌C程序之前预期的前pression [英] expected expression before ‘{’ token c program
本文介绍了“{”令牌C程序之前预期的前pression的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
编译code的这一部分时,我写以下code我解决一个难题我
I wrote following code I am solving a puzzle I when compiled this part of code
#include <stdio.h>
int main ()
{
int a[10],b[10],c[10];
int i,j,k,l;
a[10]={"21","33","12","19","15","17","11","12","34","10"};
b[10]={"10","15","9","13","16","21","15","32","29","7"};
c[10]={"11","8","3","6","1","4","6","20","19","3"};
l=sizeof(a)/sizeof(a[0]);
for (i=0;i<=l;i++)
{
}
}
给我误差
array.c: In function ‘main’:
array.c:7:8: error: expected expression before ‘{’ token
array.c:8:8: error: expected expression before ‘{’ token
array.c:9:8: error: expected expression before ‘{’ token
为什么错误来这里?
Why is the error coming here?
推荐答案
有在你的code以下几个问题:
There's several problems in your code:
- 您应该初始化数组在同一行声明它们
- 您必须使用数字数组初始化它们,而不是与C-字符串数组:
- 您实际尝试值设置为数组的元素11'th。
code的正确的路线将是:
Correct line of code will be:
int a[10] = {21,33,12,19,15,17,11,12,34,10};
这篇关于“{”令牌C程序之前预期的前pression的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文