请问:error: expected primary-expression before '[' token 该怎么解决?

程序及错误如图:图片说明

0

2个回答

对你着只发图不步伐代码的人,以后尽量少提问。费事。。。
按照下面改

typedef struct package{      
    double p;
    double w;
} pack;
pack [N+1];

0

编写一函数,判断一字符串是否为回文。所谓“回文”是指顺读和倒读都一样的字符串,如“deed”和“level”是回文。在主函数中对输入的5个字符串统计其中回文的个数。
#include
#include
int main()
{ int HW(char str[]);
char str[5][80];
char string[80];
int i,s=0;
printf("Please enter 5 string:\n");
for (i=0;i<5;i++)
scanf("%s",str);
if(HW(str*))
s=s+1;
printf("回文字符串有%d个",s);

}

int HW(char str[])
{
int i;
int L=strlen(str);
for(i=0;i<L/2;i++)
if(str[i]!=str[L-i-1])
return 0;
return 1;
}

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
error: expected primary-expression before ‘*’ token
各位好,小弟初学c++在qt先编译这个函数的时候出现问题,请大家帮忙分析下。谢谢!~rnrnvoid ImageViewer::canny()rnrn const QImage * image;rn IplImage * pImg =NULL;rn IplImage * QImageToIplImage(const QImage * qImage);rn pImg = IplImage * QImageToIplImage(image);rn cvCanny(pImg, pCannyImg, 50, 150, 3);rnrn;rnrn编译时候这块出现rnI/usr/local/Trolltech/Qt-4.7.3/include -I/usr/local/include/opencv -I. -I../imageviewerCanny -I. -o imageviewer.o ../imageviewerCanny/imageviewer.cpprn[color=#FF0000]../imageviewerCanny/imageviewer.cpp: In member function ‘void ImageViewer::canny()’:rn../imageviewerCanny/imageviewer.cpp:303: error: expected primary-expression before ‘*’ token[/color]rnmake:离开目录“/root/桌面/imageviewer-build-desktop”rnmake: *** [imageviewer.o] 错误 1rnThe process "/usr/bin/make" exited with code %2.rnError while building project imageviewer (target: Desktop)rnWhen executing build step 'Make'[color=#FF0000][/color]
expected primary-expression before ']' token
以下代码:rnvoid function (char a[])rnint main()rnrn ......rn char a[20];rn function (a);rn ......rn return 0;rnrnrnvoidfunction (char a[])rnrn a[] = "jhbcakhba";rn ......rn return;rnrnrn为什么会出现RT的错误提示?错误行是" a[] = "jhbcakhba"; "rn求解啊
求助expected primary-expression before '=' token 如何解决
哪位高手帮忙看下哪里出问题了.rn代码如下:rnrn#includernusing namespace std;rn#define Pi=3.1415926rnclass CIRCLErn private:rn float mfR;rn public:rn CIRCLE(float fR);rn void OutputArea();rn void OutputCircum();rn ;rnint main()rnrn CIRCLE a(1.23),b(5.67);rn a.OutputArea();rn a.OutputCircum();rn b.OutputArea();rn b.OutputCircum();rn system("pause");rn return 0;rnrnCIRCLE::CIRCLE(float fR)rnrn mfR=fR;rnrnvoid CIRCLE::OutputArea()rnrn cout<<"The area is :"<
error: expected ')' before '&' token
编译一个“约分分数为最简分式”程序时遇到 error: expected ')' before '&' tokenrn代码如下:rn[code=c]#include rnrn/* prototype */rnvoid reduce(int numerator, int denominator,rn int *reduced_numerator, int *reduced_denominator);rnrnint main(void)rnrn int m, n, reduced_m, reduced_n;rnrn printf("Enter a fraction: ");rn scanf("%d/%d", &m, &n);rnrn void reduce(m, n, &reduced_m, &reduced_n); //错误显示在这行rnrn printf("In lowest terms: %d/%d\n", reduced_m, reduced_n);rnrn return 0;rnrnrnvoid reduce(int numerator, int denominator,rn int *reduced_numerator, int *reduced_denominator)rnrn int mod, m, n;rnrn m = numerator;rn n = denominator;rnrn while (n != 0) rn mod = m % n;rn m = n;rn n = mod;rn rnrn *reduced_numerator = numerator / m;rn *reduced_denominator = denominator / m;rnrn[/code]
error: expected ‘)’ before ‘*’ token
我用gcc编译的时候出现了这样的错误,代码如下rnvoid addarpcache(u_int8_t *([color=#FF0000]出错点)[/color]ha,u_int8_t *pa)rnint checkarpcache(u_int8_t *([color=#FF0000]出错点[/color])ha,u_int8_t *pa)rnint arrayequal(u_int8_t *([color=#FF0000]出错点[/color])a,u_int8_t *b)rn这三个函数定义的地方都是这错误,是不是我写的形参格式不对呢?还是其他原因呢rn各位大侠帮帮忙看看哪。。。。。。。@~@rnrnrn
expected primary-expression before ']' token大神帮帮忙
#include"stdio.h"rn#include"stdlib.h"rnrnvoid select_sort(int a[],int n)rn//将a中的数按从小到大排列 rnrn int temp,j,i,k;rn for(i=0;i
expected primary-expression before ']' token 这是什么错误
G:\C++初级\string2.cpp In constructor `String::String()': rn54 G:\C++初级\string2.cpp expected primary-expression before ']' token rnrn以上就是错误的提示,知道的请告知下,谢谢rnrn#includern#includernusing namespace std;rnrnclass Stringrnrnprivate:rn char *ptr;rnpublic:rn String();rn String(char *s);rn String(const String &src);rn ~String();rnrn String& operator = (const String &src)rn rn cpy(src.ptr); return *this;rn rnrn String& operator = (char *s)rn rn cpy(s); return *this;rn rnrn String operator + (char *s);rnrn int operator == (const String &other);rn operator char*() return ptr;rnrn void cat(char *s);rn void cpy(char *s);rn rn;rnrn int main()rn rn String a,b,c;rn a = "I";rn b = "am";rn c = "so";rn String d = a + b + c + "very happpy!\n";rn cout<
请教:为什么出现 expected primary-expression before '' token
为什么出现 expected primary-expression before '' tokenrn 悬赏分:30 - 离问题结束还有 14 天 23 小时 rn/*4.已知顺序表L递增有序,编写一个算法,将X插入到先心病的适当位置上,以保持线性表的有序性。*/rn#define OK 1rn#define ERROR 0rn#define MAXSIZE 100rn#includern#includernrntypedef structrnint elem[MAXSIZE];rn int last;rnSeqList;rnrnint InsList(SeqList *L,int e)rnif(L->last==MAXSIZE-1)rn printf("表已满,无法插入\n");rn return(ERROR);rn int k;rn for(k=L->last++;eelem[k];k--)rn L->elem[k+1]=L->elem[k];rn L->elem[k+1]=e;rn return(OK);rnrnrnint main()rnint i;rn SeqList L;rn L.elem[MAXSIZE]=1,3,6,7,9,12,34,45,46,67;rn L.last=9;rn printf("数据插入前:");rn for(i=0;i
expected primary-expression before '='
Dev C++中,建立链表,为什么总是提示22 C:\Program Files\DEV-CPP\InitList.cpp expected primary-expression before '=' token 这类错误,p=head,地址给地址有问题么?rn请大虾知道,小弟初学者,菜的地方请大家包涵~rnrn[code=C/C++]rnrn/*rn*@Version 1.0rn*@Function:Build a Listrn*@Author:Luciferrn*/rnrnrn#include rn#include rnrnrntypedef struct LNodern int data;rn struct LNode *next;rn *head,*p1,*p2;rnrnusing namespace std;rnrnint main(struct LNode *head,int n)rn int num;rn head = (struct LNode *)malloc(sizeof(struct LNode)); rn p1 = head;rn cout<<"Input:"<>p2->data; //此处是否家&注意调试 rn p1->next = p2;rn p1 = p1->next;rn while(p2->data!=NULL)rn p2 = (LNode*)malloc(sizeof(LNode));rn cin>>p2 -> data;rn p1->next = p2;rn p1 = p1->next;rn rn rn p1->next = NULL;rn p1 = head;rn p1 = p1->next;rn while(p1->data!=NULL)rn cout<data<next;rn rn getchar();rn getchar();rn return 0;rn rnrnrn[/code]
请教. 编译一直[Error] expected primary-expression before'*'token
#ifndef MAZE_CREATE_Hrn#define Maze_Create_Hrn#define ROWS 40 rn#define COLS 60rn#define DIRECTION_NUM 4rn#define DIRECTION_EAST 0rn#define DIRECTION_SOUTH 1rn#define DIRECTION_WEST 2rn#define DIRECTION_NORTH 3rn#includernusing namespace std;rntypedef struct cellrnrn bool door[DIRECTION_NUM];rncell;rnvoid create_Maze(int *cells, cell (*maze)[COLS]);rnstatic void init_Maze(int *cells, cell (*maze)[COLS]);rnstatic bool is_Connect(const int * const cells, int c1, int c2);rnstatic bool all_Connect(const int * const cells);rnstatic void union_Cells(int *cells, int c1, int c2);rn#endifrnrn/*rn* 迷宫实现类:Maze_Create.cpprn*/rn#includern#include rnrnint cells[ROWS*COLS];rncell maze[ROWS][COLS];rnvoid create_Maze(int *cells, cell (*maze)[COLS]) rnrn int direction, c1, c2;rn int CELL_NUM = ROWS*COLS;rn init_Maze(cells, maze);rn srand((unsigned)time(NULL));rn while(1)rn rn c1 = rand()%CELL_NUM;rn direction = rand()%DIRECTION_NUM;rn switch(direction)rn rn case DIRECTION_EAST:rn if(c1%COLS == COLS-1) c2 = -1;rn else c2 = c1 + 1;rn break;rn case DIRECTION_SOUTH:rn if((ROWS-1) == (c1 - c1%COLS)/COLS) c2 = -1;rn else c2 = c1 + COLS;rn break;rn case DIRECTION_WEST:rn if(c1%COLS == 0) c2 = -1;rn else c2 = c1 - 1;rn break;rn case DIRECTION_NORTH:rn if(0 == (c1 - c1%COLS)/COLS) c2 = -1;rn else c2 = c1 - COLS;rn break;rn default:rn printf("error on random numbers/n");rn exit(0);rn break;rn rn if(c2 < 0) continue;rn if(is_Connect(cells, c1, c2)) continue;rn elsern rn union_Cells(cells, c1, c2);rn maze[(c1-c1%COLS)/COLS][c1%COLS].door[direction] = true;rn maze[(c2-c2%COLS)/COLS][c2%COLS].door[(direction+2)%DIRECTION_NUM] = true;rn rn if(is_Connect(cells, 0, CELL_NUM - 1)) break; rn rnrnvoid init_Maze(int *cells, cell (*maze)[COLS])rnrn int i, j, k;rn for(i = 0; i < ROWS; i++)rn rn for(j = 0; j < COLS; j++)rn rn for(k = 0; k < DIRECTION_NUM; k++)rn maze[i][j].door[k] = false;rn rn rn maze[0][0].door[DIRECTION_WEST] = true;rn maze[ROWS-1][COLS-1].door[DIRECTION_EAST] = true;rnrn for(i = 0; i < ROWS*COLS; i++)rn rn cells[i] = -1;rn rnrnbool is_Connect(const int * const cells, int c1, int c2)rnrn while(cells[c1] >= 0) c1 = cells[c1];rn while(cells[c2] >= 0) c2 = cells[c2];rn if(c1 == c2) rn return true;rn else rn return false;rnrn/*rn* if the two adjacent rooms are not connect, remove the wall between them(or fix a door)rn*/rnvoid union_Cells(int *cells, int c1, int c2)rnrn while(cells[c1] >= 0) c1 = cells[c1];rn while(cells[c2] >= 0) c2 = cells[c2];rn if(cells[c1] > cells[c2])rn rn cells[c1] = c2; rn rn elsern rn if(cells[c1] == cells[c2]) cells[c1]--;rn cells[c2] = c1;rn rnrnbool all_Connect(const int * const cells)rnrn int i, count_root = 0;rn for(i = 0; i < ROWS*COLS; i++)rn rn if(cells[i] < 0) count_root++;rn rn if(1 == count_root) rn return true;rn else rn return false;rnrnint main()rnrn int *cells;rn create_Maze(cells,cell*maze[COLS]);rnrn一个生成迷宫的程序,函数已经写好了,但是主程序引用一直出错,暂时看不出怎么改,各位帮帮忙。
C语言错误 [Error] expected primary-expression before ')' token
编写一函数,判断一字符串是否为回文。所谓“回文”是指顺读和倒读都一样的字符串,如“deed”和“level”是回文。在主函数中对输入的5个字符串统计其中回文的个数。rn#includern#includernint main()rn int HW(char str[]);rn char str[5][80];rn char string[80];rn int i,s=0;rn printf("Please enter 5 string:\n");rn for (i=0;i<5;i++)rn scanf("%s",str);rn [color=#FF0000]if(HW(str*))[/color]rn s=s+1;rn printf("回文字符串有%d个",s);rn rnrnrnint HW(char str[])rnrn int i; rn int L=strlen(str);rn for(i=0;i
[Error] expected primary-expression before ']' token出现这样的错误为什么
#include "findAlgorithm.h"rntemplate rn/***************************************************rn普通查找normal_find(数组名,所查找对象) rn***************************************************/rnint FindAlgorithm::normal_find(Keytype key[],Keytype find_obj)rnrn int length_of_key=sizeof(key);rn int i;rn for( i=0;irnint FindAlgorithm::half_find(Keytype key[],Keytype find_obj,int head,int end,int rise_or_descend)rnrn if(head>end)rn return -1;rn else if(key[(head+end)/2]==find_obj)rn return (head+end)/2;rn else if(key[(head+end)/2]>find_obj)rn rn if(rise_or_descend==1)rn half_find(key[],find_obj,head,(head+end)/2-1,1);rn elsern half_find(key[],find_obj,(head+end)/2+1,end,2);rn rn elsern rn if(rise_or_descend==1) rn half_find(key[],find_obj,(head+end)/2+1,end,1);rn elsern half_find(key[],find_obj,head,(head+end)/2-1,2);rn rn
|error: expected type-specifier before '(' token|
初学者的问题,在看视频的时候老师是可以运行的,但我用vs和codeblock都不能运行,代码我是照着打下来的,应该没错,那么这个是编译器问题还是我真的打错了....#includenusing namespace std;nn#include"string"n#includen#includen#include"set"n#includen#include"functional"nn//函数对象ntemplatenclass shownnpublic:n void operator(T &t)n n cout << t << " ";n nnprivate:nn;nnvoid main()nn cout << "hello wordl" << endl;n system("pause");n return 0;n
C [Error] expected primary-expression before 'struct' 求助。。。
#include rnrnstruct names rn char * fname;rn char * lname;rn; rnvoid getinfo(struct names);rnrnint main(void)rn struct names accountant="xingyue","yehun";rn printf("The accountant's name is %s %s",accountant.fname,accountant.lname);rn getinfo(struct names accountant);rn printf("The accountant's name is %s %S",accountant.fname,accountant.lname);rnrnvoid getinfo(struct names accountant)rn printf("please enter your first name");rn gets(accountant.fname);rn printf("please enter your last name");rn gets(accountant.lname);rn
这个怎么会有expected primary-expression before '->' token 的提示?
代码如下:rn#include rn#include rn#include rn#define SIZE 100 rnstruct newwordrnrn char word[SIZE][SIZE];rn struct newword *next;rn ;rnstruct newword *head,*current,*prev;rn main() rn rnchar buf[SIZE][SIZE]="愚蠢",rn "慌张",rn "犹豫"; rn rnfor(int i=0;i <4;i++) rnrnstrcpy(newword->word[i],buf[i]);rnprintf("输入的词语:%s\n",newword->word[i]); rnrn
出现expected primary-expression befor ""token
#include rn#include rn#include rn#include rn#include rn#define M 30rn#define N 10000rnrnrn struct Lnodern rn char code[20];rn char name[80];rn int price;rn Lnode *next;rn ; //定义商品的数据结构 rnrntypedef Lnode *SqList; //商品结构体指针类型 rnrnint sum = 0; //价格总计 rnint goodnum = 0; //商品数总计 rn//int NUMBER[N]; rnchar str[N][80];rnrnint NUMBER=0;rnrnint Listname(char str[][80], char name[]); rnvoid Listrecord(Lnode *head); rnint Listsearch(SqList &L, char code2[],Lnode *head); rnvoid Listfoundinformation(SqList &L,Lnode *head); rnvoid Listsert(SqList &L,Lnode *head); rnvoid ListDelete(Lnode *head, char code[],Lnode *head); rnvoid ListDelete2(SqList &L, char code[],Lnode *head); rnvoid Listpint(Lnode *head); rnvoid Listallpint(SqList L); rnrnrnrn int main()rnrn char code2[20];rn char ch;rn SqList L;rn int x, i, s;rn Lnode *head;rnrn head = new struct Lnode;rn head=L; rn if(head == NULL)rn rn printf("the memory is not enough!");rn return 0;rn rn elsern head->next = NULL; //令头指针指向空 rn rn printf("Please input the information of the good:\n");rnrnrn rn while(1) //输入初始商品信息rn rn Listfoundinformation(L,head);rnrn printf("Do you want to continue(YES 1 or NO 0):");rn scanf("%d", &s);rnrn if(s==0)rn break; //退出循环 rn rn rn rn printf("output print 1 or 0 :");// 查找商品信息rn ch = getchar();rn while (ch == '1') rn rn printf("please input the good's code:");rn scanf("%s", code2);rn Listsearch(L, code2,head); //调用查找函数 rn printf("if you want to continue please 1 ,other 0:");rn ch = getchar();rn rn system("cls");rn rnrn printf("if you want to delete good information(input 1 or 0):");//删除商品信息rn scanf("%d", &x);rn while (x == 1)rn rn printf("\ninput code:");rn scanf("%s", code2);rn ListDelete(L, code2,head); //调用删除函数 rn rn rnrnrn printf("\nif want to insert the good information 1 0r 0:");//插入商品信息rn scanf("%d", &x);rn while(x == 1)rn rn Listsert(L,head); //调用插入函数 rn printf("\nCONTINUE OR NOT(1 or 0):");rn scanf("%d", &x);rn rnrnrn printf("\nif you want to sell the good please input 1 other 0 :");//出售商品rn ch = getchar();rn if(ch == '1')rn Listpint(L); //sum 和 goodsum都是外部变量不需要返回值 rn printf("\nthe sum price of all good is %d", sum);rn printf("\nthe number of all goods is %d",goodnum);rn system("cls");rnrnrn printf("if you want to print the all information(1 or 0):");//商品总货清单rn scanf("%d", &x);rn if(x == 1)rn Listallpint(L);rnrnrn rnrnrnrnrnvoid Listfoundinforation(SqList &L,Lnode *head)rnrn char name[80];rn char code[20];rn int price, i;rn Lnode *pnew;rnrn printf("please input the code:");rn scanf("%s", code); //编号 rn printf("\nplease input the name:");rn scanf("%s" , name); //商品名称 rn fflush(stdin);rn printf("\nplease input the price:");rn scanf("%d", &price); //价格 rnrn pnew = new struct Lnode;rn if(pnew == NULL)rn rn printf("the room is not enough");rn return ;rn rn rn strcpy(pnew->code , code);rn strcpy(pnew->name , name);rn pnew->price = price;rn head=pnew;rn rn NUMBER=1;rnrnrnrnvoid Listsert(SqList &L ,Lnode *head)rnrn char name[80];rn char code[20];rn int price;rn int i;rn Lnode *pnew, *p;rnrn printf("CODE:");rn scanf("%s",code);rn printf("\nNAME:");rn scanf("%s", name);rn fflush(stdin);rn printf("\nPRICE:");rn scanf("%d", &price);rnrn pnew = new struct Lnode;rn if(pnew = NULL)rn rn printf("the memory is not enough!");rn return;rn rn strcpy(pnew->code , code);rn strcpy(pnew->name , name);rn pnew->price = price;rn pnew->next=NULL;rn p->next=head->next;rn p=head->next; rn rnrnvoid Listsearch(SqList L, char code2[],Lnode *head)rnrn int i, j;rn char name[80];rn Lnode *q;rn for(q = head; q!=NULL;q = q->next)rn rn if(strcmp(q->code, code2) == 0)rn break;rn rn if(q=NULL) printf("The good is not exist!");rn else rn printf("编号 名称 价格 数量\n");rn printf("%-10c%-10c%-10d%\n", q->code, q->name, q->price);rn printf("------------------------------------------------------------------\n");rn printf("\n");rn rn rn rnrnrnrnvoid ListDelete(SqList &L, Lnode *head,char code[])rnrn Lnode *q , *h;rn int i;rnrn q = head;rn h = q->next;rn while(h->code != code)rn rn q = q->next;rn h = q ->next;rn rn rn i = Listname(str[][80], h->name);rn if(i == -1)rn rn printf("the code is not exist!\n");rn return;rn rn rn free(h);rnrnrnrnvoid ListDelete2(SqList &L, char code[],Lnode *head)rnrn int i;rn Lnode *q , *p;rn q = head;rn p = q->next;rnrn while(q->next->code != code)rn rn q = q->next;rn p = q ->next;rn rnrn i = Listname(str[][80], p->name);rn rnrn rn printf("%-10c%-10d%\n", p->name, p->price);rn printf("\n");rnrn sum += p->price;rn goodnum++;rnrn q->next = p->next;rn free(p);rn rnrnrnrnrn rnrnvoid Listpint(SqList &L,Lnode *head)rnrnrn int x = 1;rn int price;rn char name[80], code[20];rn rn printf("\t\t\t\t\t编号 名称 价格 数量\n");rn while(x)rn rn printf("编号:");rn scanf("%s", code);rn ListDelete(L, head,code);rn printf("\ncontinue or not (1 or 0):");rn scanf("%d", &x);rn rn return;rnrnrnrnvoid Listallprint(Lnode *head)rnrn Lnode *q;rn int i;rnrn q = head->next;rn printf("编号 名称 价格 数量\n");rn while(q->next != NULL)rn rn i = Listname(str[][80], q->name);rn rn printf("%-10c%-10c%-10.2f\n", q->code, q->name, q->price);rn printf("------------------------------------------------------------------\n");rn printf("\n");rn rnrn printf("\n");rn printf("\n");rn printf("\n");rn printf("\t\t\t\t");rn printf("商品存货信息");rn printf("------------------------------------------------------");rnrn q = head->next;rn while(q->next != NULL)rn rn i = Listname(str[][80],q->name);rn if(i < M)rn printf("the good of %d is not enough ,please buy some\n", str[i]);rn rn
expected identifier before ‘(’ token
[code=C/C++]#include rn#include rn#include rn#include rn#include rn#include rnrn#define MAXDEFFER 1024rnint main(int argc,char *argv[])rnrn int fd,i;rn char buff[MAXDEFFER];rn if((fd=open(argv[1],O_RDONLY))==-1)rn perror("open");rn return 1;rn rn rn while(!fd.EOF)rn read(fd,buff,MAXDEFFER);rn printf("%s",buff);rn rn return 0;rn[/code]rnrn请问这是怎么一回事の~~~
expected initializer before '<' token
[code=C/C++]我用的是codeblocksrn// expected initializer before '<' token 下面这句编译出错了,不知道为什么?rn // 定义类型别名rn typedef std::vector VecType;rnrn//这道题是要传进迭代器,T应该就会实例化成为迭代器类型,为什么还可以这样子使用T::value_type呢?rn//迭代器里面也有value_type这个定义,value_type不是在容器里面的吗?》rn#include rn#include rn#include rn#include rn//using namespace std;rnrntemplate rntypename T::value_type MostFreq( T first, T last )rnrn // 计算需分配内存的大小rn std::size_t amount = 0;rn T start = first;rn while ( start != last )rn rn amount++;rn start++;rn rnrn // 定义类型别名rn typedef std::vector VecType;rnrn // 创建vector对象,用于保存输入序列的副本rn VecType vec(amount);rn VecType::iterator newFirst = vec.begin();rn VecType::iterator newLast = vec.end();rnrn // 将输入序列复制到vector对象rn std::uninitialized_copy( first, last, newFirst );rnrn std::sort ( newFirst, newLast ); // 对副本序列排序,使得相同的值出现在相邻位置rn std::size_t maxOccu = 0, occu = 0; // 出现最频繁的次数,当前值的出现次数rn VecType::iterator preIter = newFirst; //指向当前值的前一个值rn VecType::iterator maxOccuElement = newFirst; // 指向当前出现最频繁的值rnrn while( newFirst != newLast )rn rn if ( *newFirst != *preIter ) // 当前值与前一值不同rn rn if ( occu > maxOccu ) // 当前值的出现次数为目前最大次数rn rn maxOccu = occu; // 修改最大次数rn maxOccuElement = preIter; // 修改指向当前出现最频繁的值的迭代器rn rn occu = 0;rn rn ++occu;rn preIter = newFirst;rn ++newFirst;rn rn // 最后一个值的出现次数与目前的最大次数进行比较rn if ( occu > maxOccu )rn rn maxOccu = occu;rn maxOccuElement = preIter;rn rnrn return *maxOccuElement;rnrnrnrnint main ()rn rnrnrn return 0;rnrn[/code]
expected expression before ‘/’ token
int main(int argc, char* argv[])rnrn int width = 0;rn int height = 0;rn struct _LipStep1 * p_step1 = NULL;rn FtkWidget* win = NULL;rn FtkWidget* button = NULL;rn FtkWidget* img = NULL;rn FtkWidget* img_manager = NULL;rn PImgListManager p_manager = NULL;rn char file_name[128];rnrn p_step1 = malloc(sizeof(*p_step1));rn ret_val_if_fail(p_step1 != NULL, RET_FAIL);rn win = ftk_app_window_create();rn width = ftk_widget_width(win);rn height = ftk_widget_height(win);rnrn p_manager = img_list_create();rn snprintf(file_name,sizeof(file_name),"%s%s",DATA_DIR,"lip0.bmp"); //[color=#FF0000][/color expected expression before ‘/’ tokenrn rn img_list_insert(p_manager,img_list_ele_create(file_name));rn img = ftk_image_create(win, 300, 0, 100, 100);rn snprintf(file_name,sizeof(file_name),"%s%s",DATA_DIR,"step_1.bmp"); //[color=#FF0000][/color expected expression before ‘/’ tokenrn ftk_image_set_image(img,ftk_bitmap_factory_load(ftk_default_bitmap_factory(), file_name));rnrn p_step1->win = win;rn p_step1->img_manager = img_manager;rnrn button = ftk_button_create(win,310,height - 80,80,40);rn ftk_widget_set_text(button,"下一步");rn ftk_button_set_clicked_listener(button,button_winstep1_next,p_step1);rnrn button = ftk_button_create(win,310,height - 40,80,40);rn ftk_widget_set_text(button,"退出");rn ftk_button_set_clicked_listener(button,button_winstep1_quit,p_step1);rnrn ftk_widget_set_text(win,"唇彩试妆-步骤1");rn ftk_widget_show_all(win,1);rn ftk_widget_set_attr(win, FTK_ATTR_IGNORE_CLOSE);rnrn return RET_OK;rnrnrn错误有两处,已标出,请各位 高手帮帮忙啊。rn还有那个snprintf()函数的用法是怎么样的,怎么两个错误都 出现在那里呢?
expected unqualified-id before '->' token
最近在练习c++时,用c++的类来写一个双向循环链表,出现了以下错误,请问代码哪里错了[code=c]#ifndef L_I_N_K_P_S_Nrn#define L_I_N_K_P_S_Nrnrn#include rnrntemplate rnstruct node rn node(): prev(nullptr), next(nullptr), value(-1) ;rn node *prev, *next;rn datatype value;rn;rnrn//typedef node Node;rnrntemplate rnclass link rnpublic:rn typedef unsigned size_type;rn //link() = default;rn // link(initializer_list ls)rn link() = default;rnrn void insert(datatype t);rn node* search(datatype t);rn std::string deletes(datatype t);rnprivate:rn node nil;rn typename node::nil->prev = &nil, node::nil->next = &nil; //编译出来是这行错了,请问为什么rn; rn错误信息如下[code=c]error: expected unqualified-id before '->' tokenrn typename node::nil->prev = &nil, node::nil->next = &nil;[/code]rn#endif[/code]
局域网聊天室 error: expected class-name before '' token
准备用Qt Creator 编写一个简单的局域网聊天室,哪知刚开始就出现了错误 error: expected class-name before '' tokenrnrn头文件 tcpClientSocket.hrnrn#ifndef TCPCLIENTSOCKET_Hrn#define TCPCLIENTSOCKET_Hrn#include rn#include rnrnclass TcpClientSocket : public QTcpSocketrnrn Q_OBJECTrnpublic:rn TcpClientSocket(QObject *parent=0);rn ~TcpClientSocket();rnrn;rnrn#endif // TCPCLIENTSOCKET_Hrnrn源文件还没怎么写 tcpClientSocket.cpprnrn#include "tcpClientSocket.h"rnrnTcpClientSocket::TcpClientSocket(QObject *parent)rnrnrnTcpClientSocket::~TcpClientSocket()rnrnrnrnrn一但rebuild这个工程,就会出现rnerror: expected class-name before '' tokenrnrn大家帮我看看到底是什么原因,应该怎么处理?rn
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘’ token
hello.c code:rn#includernvoid mainrnrn printf("hello work!");rnrnrncompile:$ cc helloWork.crnhelloWork.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘’ tokenrnrnrnwhy??rn
C语言编译error:expected ')' before '*' token
[code=C/C++]rn/*************************************************************rn *rn * operate BitTreern *rn ************************************************************/rn#include rn#include rn#include rnrntypedef struct BitNodernrn char ele;rn struct BitNode *lchild;rn struct BitNode *rchild;rn*BitTree;rnrntypedef struct stackrnrn BitTree BTP;rn struct stack *next;rn*stackP;rnrnint i=0;rn//according to picture 6.8rnchar bitTreeArr[]='A','B','C','#','#','D','E','#','G','#','#','F','#','#','#';rnrnvoid FinOrderTraverse(BitTree p)rnrn if(p!=NULL)rn rn FinOrderTraverse(p->lchild);rn FinOrderTraverse(p->rchild);rn printf("%c ",p->ele);rn rnrnrn->void pushInStack(stackp *head,BitTree p)rnrn stackp sp;rn if((sp=malloc(sizeof(struct stack)))==NULL)rn rn printf("overflow,malloc failed in pushInStack.\n");rn exit(1);rn rn if(*head==NULL)rn rn *head=sp;rn rn elsern rn sp->next=*head;rn *head=sp;rn rnrnrn->void popStack(stackp *head,BitTree *p)rnrn stackp sp;rn sp=*head;rn *head=sp->next;rn *p=sp->BTP;rn free(sp);rnrnrnvoid MidInorderTraverse(BitTree p)rnrn stackP head=NULL;rn while(p!=NULL || head!=NULL)rn rn if(p)rn rn pushInStack(&head,p);rn p=p->lchild;rn rn elsern rn popStack(&head,&p);rn printf("%c ",p->ele);rn p=p->rchild;rn rn rnrnrnvoid MidOrderTraverse(BitTree p)rn rn if(p!=NULL)rn rn MidOrderTraverse(p->lchild);rn printf("%c ",p->ele);rn MidOrderTraverse(p->rchild);rn rnrnrnvoid PreOrderTraverse(BitTree p)rnrn if(p!=NULL)rn rn printf("%c ",p->ele);rn PreOrderTraverse(p->lchild);rn PreOrderTraverse(p->rchild);rn rnrnrnvoid createBitTree(BitTree *BT)rnrn if(iele=bitTreeArr[i];rn i++;rn createBitTree(&(*BT)->lchild);rn createBitTree(&(*BT)->rchild);rn rn rn rnrnrnint main()rnrn void createBitTree(BitTree *p);rn void PreOrderTraverse(BitTree p);rn void MidOrderTraverse(BitTree p);rn void FinOrderTraverse(BitTree p);rn ->void pushInStack(stackp *head,BitTree p);rn ->void popStack(stackp *head,BitTree *p);rn void MidInorderTraverse(BitTree p);rn BitTree head;rn createBitTree(&head); //create BitTreern rn printf("BitTree nodes print in preOrder are:");rn PreOrderTraverse(head); //preOrder traverse BitTreern printf("\n");rn rn printf("BitTree nodes print in midOrder are:");rn MidOrderTraverse(head); //midOrder traverse BitTreern printf("\n");rn rn printf("BitTree nodes print in finOrder are:");rn FinOrderTraverse(head); //finOrder traverse BitTreern printf("\n");rn rn printf("BitTree nodes print in midInOrder are:");rn MidInorderTraverse(head);rn printf("\n");rnrn[/code]rnrn编译时出错rnerror:expected ')' before '*' tokenrnrn出错行已在上面标示rn
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
编译时遇到这个错误,应该如何解呢
error: expected '=', ',', ';', 'asm' or '__attribute__' before '==' token
运算符重载rnboolean_t operator==(thread_t& thd_a, thread_t& thd_b)rnrn return (&thd_a == &thd_b);rnrnerror: expected '=', ',', ';', 'asm' or '__attribute__' before '==' tokenrnrn函数模板rnerror: expected '=', ',', ';', 'asm' or '__attribute__' before '<' tokenrntemplaternstatic inline void list_free(list_t* plst);rnrn代码明明没问题啊,这是怎么了?
error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
[code=C/C++]rnrn#ifndef _UT_TYPES_H_rn#define _UT_TYPES_H_rnrn#include rn#include rnrn// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$rn// $$$$$$$$$$$$$$$$$$$$common$$$$$$$$$$$$$$$$$$$$$rnrn#if defined WIN32 || WINCErn typedef __int64 S_INT64;rn typedef unsigned __int64 U_INT64;rn#define ATOI64(val) _atoi64(val)rn#elif defined (LINUX_PC) || defined (LINUX_PDA) || defined (ANDROID_PHONE) || defined (SYMBIAN_PHONE)rn typedef long long S_INT64;rn typedef unsigned long long U_INT64;rn #define ATOI64(val) strtoll(val, NULL, 10)rn typedef long long __int64;rn#endifrnrn#if defined WIN32 || WINCErn #define STDCALL __stdcall* rn#elif defined (LINUX_PC) || defined (LINUX_PDA) || defined (ANDROID_PHONE) || defined (SYMBIAN_PHONE)rn #define STDCALL *rn#endifrnrn#define MAXLEN_OF_PATH 256 // ¬∑æ∂◊Ó¥Û≥§∂»rnrnrn#define INrn#define OUTrn#define INOUTrnrntemplate rn提示rnut_types.h:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' tokenrnrnrnrnrn[/code]
[Error] expected '=', ',', ';', 'asm' or '__attribute__' before '' token
[img=https://img-bbs.csdn.net/upload/201710/03/1507041265_869989.png][/img]rn[img=https://img-bbs.csdn.net/upload/201710/03/1507041276_828324.png][/img]rn[img=https://img-bbs.csdn.net/upload/201710/03/1507041285_128912.png][/img]rn[img=https://img-bbs.csdn.net/upload/201710/03/1507041294_701851.png][/img]rnrn[Error] expected '=', ',', ';', 'asm' or '__attribute__' before '' tokenrn我找半天也没找到错误在哪里。。
expected primary-expression before const什么错啊!
[code=C/C++]rn#include rn#include rn#include rn#include rnint main()rn const vector::size_type st=10;rn vector vs(st,"xx");rn return 0;rnrnrn[/code]rn就这样很短的一段代码,怎么还报错啊!
错误:expected initializer before '.' token
在头文件中定义一个 全局变量static QMappooln在源文件函数中初始化pool QMap address_pool::pool.insert(i,IP);n然后就报错,大神们求解决,困恼了2天了
编译错误:expected template-name before ‘<’ token
template rnrnclass graphrnrnrnrn public:rnrn [color=#FF0000]class const_iterator: public map< T, int >::const_iteratorrn[/color]rn rnrn public:rn......rn红色的那行有错误,不知道为何?rn初学者,谢谢帮忙!rn
expected primary expression before '%' token
http://acm.hrbeu.edu.cn/index.php?act=problem&id=1001&cid=20rnrnValid date formatrnrncode:rn#includern#includernchar yuefen[13][5]="Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec";rnint getyue(char a[])rnrn int i,yue;rn for(i=0;i<12;i++)rn rn if(strcmp(a,yuefen[i])==0)rn rn yue=i+1;rn return yue;rn rn rn return -1;rnrnrnint leap(int y)rnrn if((y%4==0&&y%100!=0)||(y%400==0))rn return 1;rn else return 0;rnrnrnint judge(int m,int d,int y)rnrn if((y>1000)&&(m==1||m==3||m==5||m==7||m==8||m==10||m==12)&&(d>0&&d<=31))rn return 1;rn else if((y>1000)&&(m==4||m==6||m==9||m==11)&&(d>0&&d<=30))rn return 1;rn else if((y>1000)&&leap(y)==1&&m==2&&(d>0&&d<=29))rn return 1;rn else if((y>1000)&&leap(y)==0&&m==2&&(d>0&&d<=28))rn return 1;rn else return 0;rnrnrnint main()rnrn char str[50],yue[10];rn int d,m,y,flag;rn while(gets(str))rn rn if(str[2]=='-'&&str[5]=='-')rn rn sscanf(str,"%d-%d-%d",&m,&d,&y);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else if(str[2]=='-'&&(str[3]>='A'&&str[3]<='S'))rn rn sscanf(str,"%d-%[^-]-%d",%d,yue,&y); //明明照着书上敲的 咋编译错误啊rn m=getyue(yue);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else if(str[2]=='/'&&str[5]=='/')rn rn sscanf(str,"%d/%d/%d",&m,&d,&y);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else if(str[4]=='/'&&str[7]=='/')rn rn sscanf(str,"%d/%d/%d",&y,&m,&d);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else if(str[4]=='/'&&(str[5]>='A'&&str[3]<='S'))rn rn sscanf(str,"%d/%[^/]/%d",&y,yue,&d);rn m=getyue(yue);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else printf("Invalid\n");rn rn return 0;rnrnrnrn额 发现手残打错东西了···rn应该是&d····rn好吧 请问各位大神%[^-]是什么意思?rn以前从来都没见过
expected initializer before '<' token问题
#includernusing namespace std;rntemplaternstruct BiNodernrn DataType data;rn BiNode*lchild,*rchild;rn;rntemplaternclass BiTreernrn public:rn BiTree()root=Creat(root);rn rn ~BiTree()Release(root);rn rn void PreOrder()PreOrder(root);rn rn private:rn BiNode*root;rn BiNode*Creat(BiNode*bt);rn void Release(BiNode*bt);rn void PreOrder(BiNode*bt);rn;rntemplaternvoid BiTree::PreOrder(BiNode*bt)rnrn if(bt==NULL)return;rn elsern cout<data;rn PreOrder(bt->lchild);rn PreOrder(bt->rchild);rn rnrntemplatern[u][i]BiNode*Bitree::Creat(BiNode*bt)[/u]rnrn cin>>ch;rn if(ch=='#')bt=NULL;rn elsern bt=new BiNode;rn bt->data=ch;rn bt->lchild=Creat(bt->lchild);rn bt->rchild=CREAT(bt->rchild);rn rn return bt;rnrnmain()rnrn BiTree BT;rn BiNode*root;rn BT.PreOrder();rnrn错误是这个expected initializer before '<' token,rn这个是什么意思啊,怎么改rn错误在我下划线的位置
[Error] qualified-id in declaration before '(' token [Error] expected '' at end
#include rn#include rn#include rn#include rnusing namespace std;rnint N;rnclass studentrnrn public:rn void addstudent ();rn void deletestudent ();rn void findstudent ();rn void changestudent ();rn void writetofile ();rn void readfromfile ();rn void sumstudent (); rn private:rn long id;rn string name;rn string sex;rn string place;rn long telnum;rn string mail;rn rn;rnvoid student::addstudent()rnrn int i=0,t;rn cout<<"请输入要添加的人数"<>t;rn N=N+t;rn student stu[N];rn for(;i>stu[i].id>>stu[i].name>>stu[i].sex>>stu[i].place>>stu[i].telnum>>stu[i].mail;rn rnrnvoid student::deletestudent()rnrn string Name;rn int i=0,a=-1;rn cout<<"请输入要删除的学生名字"<>Name;rn student stu[N];rn for(;i>Name;rn int i=0;rn for(;i>Name;rn for(;i>a;rn while(1)rn rn switch(a)rn rn case 1:rn stu.readfromfile();rn break;rn case 2:rn stu.addstudent();rn break;rn case 3:rn stu.deletestudent();rn break;rn case 4:rn stu.findstudent();rn break;rn case 5:rn stu.changestudent();rn break;rn case 6:rn stu.sumstudent();rn break;rn case 7:rn stu.readfromfile();rn break;rn rn rnrnint main()rnrn menu();rn return 0;rn
Syntax error on token ")", ++ expected
An error occurred at line: 42 in the jsp file: /show.jsprnSyntax error on token ")", ++ expectedrn39: for(int i=0;i");rn43: out.println(""+myname_card.getID()+"");rn44: out.println(""+myname_card.getname()+"")rn45: out.println(""+myname_card.getsex()+"");
有谁帮我解决:expected primary-expression before 'unsigned'问题!
我使用g++ 4.6.1,编译一个文件,出错!错误指向的内容是这样的:rn[code=c]rn switch ( indexSize )rn rn case 1:rn index = unsigned long( *(unsigned char*)pIndexData[i * indexSize] ); break;rn case 2:rn index = unsigned long( *(unsigned short*)pIndexData[i * indexSize] ); break;rn case 4:rn index = unsigned long( *(unsigned long*)pIndexData[i * indexSize] ); break;rn case 8:rn index = unsigned long( *(unsigned long long*)pIndexData[i * indexSize] ); break;rn // 因为保证最大的索引大小是8,所以没有启用错误处理模块rn rn[/code]rn我其实想实现1字节、2字节、4字节和8字节的读取,但是错误指向了index赋值的几条语句,请问该怎么办?
expected primary-expression before "char" 怎么错了 速求
[code=c]#include rnusing namespace std;rnint read() rn rn int x=0; rn char ch=getchar(); rn while(ch<'0'||ch>'9') ch=getchar(); rn while(ch>='0'&&ch<='9') rn rn x=x*10+ch-'0'; rn ch=getchar(); rn rn return x; rnrnint my_search(int n,int m,char**a)rnrn int ans=0;rn if(n!=0&&m!=0)rn rn for(int i=n-1;i<=n+1;i++)rn rn for(int j=m-1;j<=m+1;j++)rn rn if(a[m][n]=='*')ans++;rn rn rn rn else if(n==0&&m==0)rn rn if(a[n+1][m]=='*')ans++;rn if(a[n][m+1]=='*')ans++;rn if(a[n+1][m+1]=='*')ans++;rn rn else if(n==0&&m!=0)rn rn if(a[n+1][m]=='*')ans++;rn if(a[n][m+1]=='*')ans++;rn if(a[n+1][m+1]=='*')ans++;rn if(a[n+1][m-1]=='*')ans++;rn if(a[n][m-1]=='*')ans++;rn rn else if(n!=0&&m==0)rn rn if(a[n-1][m]=='*')ans++;rn if(a[n][m+1]=='*')ans++;rn if(a[n-1][m+1]=='*')ans++;rn if(a[n+1][m+1]=='*')ans++;rn if(a[n+1][m]=='*')ans++;rn rn return ans;rnrnint main()rnrn int n=read(),m=read();rn char a[m][n];rn int b[m][n];rn for(int i=0;i>a[i][j];rn rn for(int i=0;i
求助:expected identifier or ‘(’ before ‘&’ token 函数返回引用怎么解决?
如下代码,在return t; 下面一空行报错:expected identifier or ‘(’ before ‘&’ token,怎么查都看不出哪里有格式问题:rn[code=C/C++]#include rn#include rnrnint &func(int& t)rnrn return t;rn[color=#FF0000] //This line: expected identifier or ‘(’ before ‘&’ token[/color]rnrnrnrnint main(int argc, char * argv[]) rn rn int a=0;rn int b=func(a);rn printf("&a=0X%08X,&b=%08X\n",&a,&b);rnrn return 0;rn[/code]rn把函数换成如下也是同样的错误:rn[code=C/C++]int &func(int* t)rnrn return *t;rn //This line: expected identifier or ‘(’ before ‘&’ tokenrnrn[/code]rn我用的是WinGW+eclipse+gcc,在eclipse里编译如上代码,或者命令行里用gcc编译都是报一样的错:rnexpected identifier or ‘(’ before ‘&’ tokenrnrn请大家帮忙看下这个错在哪里,怎么解决?谢谢^-^
error: expected init-declarator before "GroupNameList_t"
下边的一行位于一个头文件的内容的第一行rn#include rnrn#include rn#include rn#include rnrn#include "Application.H"rnrntypedef std::vector GroupNameList_t;rnrn编译报错:rnerror: expected init-declarator before "GroupNameList_t"rnrn请达人指点。rnrn是与 #include "Application.H" 有关?
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘. '
在Suse11.0上用交叉编译器xscale-linux-gcc编译一个库,出现如题的错误:rn“rnxscale-linux-gcc -O2 -fPIC -I. -I ../../kernel -I ../lib -DHAVE_CONFIG_H -D_U_="__attribute__((unused))" -c bpf_filter.crnbpf_filter.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ tokenrnmake: *** [bpf_filter.o] Error 1rn”rnrnbpf_filter.c文件的内容就一行:rnlink ./bpf/net/bpf_filter.crnrn我一直用的C++编程,第一次看到这样的C语言代码,现在有两个问题:rn(1)这句话是什么意思?rn(2)上面的错误该如何解决rnrn希望高手能解答一下,谢谢! rn
error: expected ',' or '...' before numeric constant
union Argrnrn bool b;rn char c;rn WORD w;rn DWORD d;rn int i;rn float f;rn INT64* I;rn void* p;rn const char* s;rn ViPacket* m;rn uint64_t* U;rnrn Arg(bool _b) b = _b;rn Arg(char _c) c = _c;rn Arg(WORD _w) w = _w;rn Arg(DWORD _d) d = _d;rn Arg(int _i) i = _i;rn Arg(float _f) f = _f;rn Arg(INT64& _I) I = &_I;rn Arg(uint64_t& _U) U = &_U;rn Arg(void* _p) p = _p;rn Arg(string& _s) s = _s.c_str();rn Arg(const char* str) s = str;rn Arg(ViPacket& _m) m = &_m;rn;rn我想问一下为什么Arg(uint64_t& _U) U = &_U;这一行会报错误,谢谢各位
相关热词 c#异步发送kafka c#窗体编号 c# 操作二进制文件 c# 反射 机制 c#线程 窗体失去响应 c#角度转弧度 c# 解析gps数据 c# vs设置 语法版本 c# json含回车 c#多线程demo