Vetores
Como eu posso passar vetores para funções e retornar vetores em uma função ?
Por exemplo, eu pensava q era assim:
#include <cstdlib>
#include <iostream>
using namespace std;
int testa(int vetor[])
{
for(int i=0; i<5; i++)
testa[i] = i+2;
return vetor;
}
int main(int argc, char *argv[])
{
int vetor[5] = {1,2,3,4,5};
testa(&vetor);
for(int i=0; i<5; i++)
cout << vetor[i] << endl;
return 0;
}Discussão (5)
Carregando comentários...