简体   繁体   中英

Unexpected token: int, processing 2.21

I'm working with processing 2.2.1, and I am 90% sure that this is syntactically correct. I keep getting an error explaining that it is incorrect with an "unexpected token: int".

void growEllipse(int ellipseHW){
    if(int i = 0; i != width*2; i++){
       ellipseHW = ellipseHW++;
  }

I have tried moving the int to within the function, like so (check below) but then I get an error saying that it is "expecting RPAREN, found ';'".

void growEllipse(int ellipseHW){
  int i;
  if(i = 0; i != width*2; i++){
    ellipseHW = ellipseHW++;
  }
}

This is rather frustrating because it seems syntactically correct. Can anybody help me figure it out?

It looks like you're trying to use a for loop , not an if statement :

for(int i = 0; i != width*2; i++){
  ellipseHW = ellipseHW++;
}

More info on the for loop can be found in the Processing reference .

尝试使用“ for”语句代替“ if”语句。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM