Could not able to solve this..
I am implementing a queue. After writing the complete code I had the error listed below:
expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
然后我写了一个简单的程序,但同样的问题仍然存在。无法理解如何解决这个问题。我研究过解决方案stackoverflow.com and google.com
查了很多,还是没能解决这个问题,请帮忙。
我想initialize globally
Q.front = Q.rear = Any value
#include <stdio.h>
#include <stdlib.h>
struct Queue
{
int front, rear;
int queue[10] ;
};
struct Queue Q;
Q.front = 0;
Q.rear = 0;
int main()
{
return 0;
}
Q.front = 0;
不是简单的初始化程序,它是可执行代码;它不能发生在函数之外。使用适当的初始化程序Q
.
struct Queue Q = {0, 0};
或者使用命名初始值设定项语法(并非在所有编译器中都可用,目前仅在 C 中可用):
struct Queue Q = {.front = 0, .rear = 0};
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)