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

  • 5 Comments sorted by Date Added Votes
  • Remove the 2 lines with curly braces before the for statement.
    Stockholm, Sweden
    I am only an egg -- Stranger in a Strange land, Robert A. Heinlein
  • 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,244
    edited April 30 Vote Up0Vote Down
    Where you have
    for(int i = startVal;... i = endval;... i = incVal)
    
    it should read
    for(int i = startVal; i != endval; i += incVal)
    
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
  • Thanks, I was able to solve it. Your help is much appreciated.
Sign In or Register to comment.