Shop OBEX P1 Docs P2 Docs Learn Events
Function help — Parallax Forums

Function help

I am trying to display the values of startVal, endVal and incVal, and have the for statement start at 10 and multiply until it reaches 100. I get an error message like this Function with Parameter (1).c:26:2: error: expected identifier or '(' before '{' token
Done. Build Failed!
Can I have some insight into what I am doing wrong? Thanks y'all.

Click error or warning messages above to debug.
#include "simpletools.h" // Include simpletools


void counter(int startVal, int endVal, int incVal); // Function prototype

int main() // main function
{
counter(6, 100, 1 * 2); // Call value function
}

void counter(int startVal, int endVal, int incVal) // value function

{
print("The value is: startVal = %d\n", startVal); // Display a single value
print("The value is: endVal = %d\n", endVal); // Display a single value
print("The value is: incVal = %d\n", incVal); // Display a single value
}
{
for(int i = startVal;... i = endval;... i = incVal)
{
print("i = %d\n", i);
}
}

Comments

  • Remove the 2 lines with curly braces before the for statement.
  • I just did that and get this error now.

    Function with Parameter (1).c: In function 'counter':
    Function with Parameter (1).c:26:23: error: expected expression before '...' token
    Function with Parameter (1).c:26:38: error: expected expression before '...' token
    Done. Build Failed!
  • DavidZemonDavidZemon Posts: 2,973
    edited 2017-04-30 20:11
    Where you have
    for(int i = startVal;... i = endval;... i = incVal)
    
    it should read
    for(int i = startVal; i != endval; i += incVal)
    
  • Thanks, I was able to solve it. Your help is much appreciated.
Sign In or Register to comment.