1
I would like to create a function that receives a file .txt
and do something with it, but I don’t know how to define the sending and receiving parameters, or if I should pass parameter by reference.
Sending the file to function: funcaoRecebeArquivo(arquivo);
I’m not sure what should be placed inside the parentheses when calling the function and sending the file. A code sketch below:
funcaoRecebeArquivo(arquivo)
{
//Receber o arquivo e fazer algo com ele aqui dentro
}
int main ()
{
FILE *sensvalid;
if ((sensvalid = fopen("X10Map.txt","r")) == NULL)
{
printf("Nao consegui abrir o arquivo X10MAP.");
return 2;
}
funcaoRecebeArquivo(arquivo);
return 0;
}
Your question is how to define the header of the function that receives the file ? If so it would be something like
void funcaoRecebeArquivo (FILE *arquivo)
– Isac
Exactly, I also need to call the function inside the main.
– Eduardo Cardoso