#include <iostream>
using namespace std;
int main()
{
int nombre, carre ;
cout << "Introduza un numero : " ;
cin >> nombre ;
carre = nombre * nombre ;
cout << "A raiz quadrada est ; " << carre ;
}
Quando compilo com o GCC:
gcc -Wall -Wextra -Werror -o calc_carre calc_carre.cpp
Obtenho:
calc_carre.cpp:(.text+0xe): undefined reference to
std::cout' calc_carre.cpp:(.text+0x13): undefined reference to
std::basic_ostream >&std::operator<< >(std::basic_ostream >&, char const*)' calc_carre.cpp:(.text+0x1f): undefined reference tostd::cin' calc_carre.cpp:(.text+0x24): undefined reference to
std::istream::operator>>(int&)' calc_carre.cpp:(.text+0x3a): undefined reference tostd::cout' calc_carre.cpp:(.text+0x3f): undefined reference to
std::basic_ostream >&std::operator<< >(std::basic_ostream >&, char const*)' calc_carre.cpp:(.text+0x4f): undefined reference tostd::ostream::operator<<(int)' /tmp/cclJ9vPR.o: In function
__static_initialization_and_destruction_0(int, int)': calc_carre.cpp:(.text+0x7d): undefined reference tostd::ios_base::Init::Init()' calc_carre.cpp:(.text+0x8c): undefined reference to
std::ios_base::Init::~Init()' collect2: error: ld returned 1 exit status
No C:
#include <stdio.h>
int main()
{
int nombre, carre ;
printf ("Introduza un numero") ;
scanf ("%d", &nombre) ;
carre = nombre * nombre ;
printf (" A sua raiz quadrada é: %d, nombre) ;
}
Quando compilo não obtenho nenhum erro, mas vejam pelos vossos olhos:
printf ("o seu quadrado é: ...", carre)