Requesting a better explanation of Arduino's C/C++

"The arduino code is actually just plain old c without all the header part (the includes and all)- "

I don't understand, are all the libraries automatically added then?

Or is this a total lie, and I need C libraries, or different syntax...

For example;

#include <stdio.h>
main()
{
(void) printf ("Hello World!\n");
return (0);
}

Doesn't work on a lot of different levels
(Initially: redefinition of 'int main()

Either way, thank you for your time.

(I'd like to learn C, and if I already have a simple, non-dos IDE available, I'd like to be using it :slight_smile:

An Arduino program has a "main" - you just don't normally see it.
It looks a bit like this:

#include <WProgram.h>

int main (void)
{
  init ();     // initialises the timers mostly. You don't see it.
  setup ();  // you provide this...
  for (;;) 
    loop ();  // ..and this
  return 0;
}

You do have to give library includes, but you don't usually have to give prototypes for your own functions (for some reason, you do if the function uses references).

Not sure why you're getting the "redef". Normally it's not a good idea to define main (or anything else) more than once but the linker is usually forgiving if you do and uses the last definition. Certainly that's what it does "at my end". That said, if you want to define your own main you can just hide (rename, delete, move) the default in ..\hardware\arduino\cores\arduino.

Here just as an example is blink rewritten without setup() and loop()

#include <WProgram.h>

int ledPin =  13;    // LED connected to digital pin 13

int main (void)
{
  init ();     // initialises the timers mostly. You don't see it.

  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);     

  for (;;)
  {
    digitalWrite(ledPin, HIGH);   // set the LED on
    delay(1000);                  // wait for a second
    digitalWrite(ledPin, LOW);    // set the LED off
    delay(1000);                  // wait for a second
  }
  return 0;
}

Bear in mind that doing it this way, the scoping inside the for loop is subtly different from inside loop()