auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while
int
numero intero
long
da -2.147.483.648 a 2.147.483.647
4 byte
float
da -3.4028235⋅10+38 a
3.4028235⋅10+38.
double
raddpppia i bit del float
char
un_carattere = ‘a’; // virgolette
singole
I/O e' affidato a funzioni di libreria.
In pratica sono universalmente accettate le funzioni di I/O scritte dai creatori del linguaggio, che quindi sono diventate uno standard de facto.
C++ inherits most of C's syntax. The following is Bjarne Stroustrup's version of the Hello world program that uses the C++ Standard Library stream facility to write a message to standard output:
#include <iostream>
int main()
{
std::cout << "Hello, world!\n";
}
utilizzare un ambiente di programmazione on-line: www.ideone.com
#include <stdio.h> int main(void) { |
#include <stdio.h> main() {
|
include nel testo del programma il file stdio.h
stdio.h contiene .... h = header
Un programma eseguibile deve obbligatoriamente restituire un numero, codice di risposta.
\n per andare a capo
1-dim, 2-dim 1D, 2D
dimensions indexes subscripts
https://www.tutorialspoint.com/arduino/arduino_multi_dimensional_arrays.htm
the C++ compiler does no checking to see if array access is within legal bounds of the array size that you have declared.
int Matrix[Y][X];
for (int i =0; i < Y; i++) {
for (int j =0; j < X; j++) {
Matrix[i][j] = some data;
}
}
int Matrix[][X] = {
{1,2,3,...,X}, // virgola
{3,4,5,...,X},
{1,9,2,...,X},
{9,8,7,...,X} // no virgola
};
// addr=addr2; invalid array
assignment
//addr = dev_id[i]; invalid array assignment
#include <iostream>
int main() {
char parole[] = "mela pera miele"; // stringa := array di caratteri
printf("parole a caso: %s", parole);
return 0;
}
in memoria la stringa viene terminata dal byte null, dal compilatore, non va scritto,
#include <file.h> | angle brackets, the libraries paths will be searched for the file. .h estension, is a header file library |
#include "file.h" | double quotes syntax, the folder of the file using the #include directive will be searched for the specified file, then the libraries paths if it was not found in the local path. Use this syntax for header files in the sketch’s folder. |
Since macros do literal source-level replacement, you will tend to get side-effects if you pass an argument to one, like "a++".
:: Scope Resolution Operator it makes it clear to which namespace or class a symbol belongs. wp | stackoverflow
es: AirlineTicket::AirlineTicket()
used to separate the
class AirlineTicket
from in this case the constructor
AirlineTicket()
, forming the qualified name
AirlineTicket::AirlineTicket()
stackoverflow/stdint.h-VS-inttypes.h