Pages: [1]   Go Down
Author Topic: sample code in reference does not compile ( IDE 022)  (Read 1472 times)
0 Members and 1 Guest are viewing this topic.
oak ridge, TN, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Here is the link:  http://www.arduino.cc/en/Reference/FunctionDeclaration

Here is the compile error: function_2_demo:6: error: function definition does not declare parameters

Here is the code that does not compile:

void setup(){
  Serial.begin(9600);
}

void loop{
  int i = 2;
  int j = 3;
  int k;

  k = myMultiplyFunction(i, j); // k now contains 6
  Serial.println(k);
  delay(500);
}

int myMultiplyFunction(int x, int y){
  int result;
  result = x * y;
  return result;
}
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like a typro/error in the reference, missing () after loop.

Quote
Here is the code that does not compile:

void setup(){
  Serial.begin(9600);
}

void loop(){
  int i = 2;
  int j = 3;
  int k;

  k = myMultiplyFunction(i, j); // k now contains 6
  Serial.println(k);
  delay(500);
}

int myMultiplyFunction(int x, int y){
  int result;
  result = x * y;
  return result;
}
Logged

oak ridge, TN, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to Retrolefty

That is indeed correct.  Now how do we get the web page corrected?
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Fixed.
Logged

Pages: [1]   Go Up
Jump to: