++ operator not working on array inside a function

More
2 days 7 hours ago #181 by ludojoey
Hi!

Inside a function, the ++ operator will not work on an array element.

Example:

void f1() {
  byte t[1];
  t[0]=1;
  t[0]++;
  print(t[0]);
}

This will print "1" (wrong)

void f1() {
  byte t[1];
  t[0]=1;
  t[0]=t[0]+1;
  print(t[0]);
}

This will print "2" (right)
 
The following user(s) said Thank You: Franck

Please Log in or Create an account to join the conversation.

Time to create page: 0.157 seconds
Powered by Kunena Forum