I need to get float
values to store in struct
, but I need to validate these values through a validation function. '
The function that validates these values is working correctly, but when I try to call it inside the function it will store inside the struct
it states: "undefined reference to ' lerfloat
'".
The function lerfloat
:
float lerfloat()
{
float f;
char c;
int ret;
do
{
puts("Insira um numero: \n");
ret=scanf("%f",&f);
fflush(stdin);
if(ret==1)
{
return f;
}
else{
puts("Digite apenas numeros por favor.\n");}
}while(ret!=1);
return f;
}
The function to store the values:
#include <stdio.h>
#include <stdlib.h>
#include "headLer.h"
struct armazenar
{
float x;
float y;
};
float func_lerVetor(float vet_pontos[][2], int n)
{
struct armazenar p;
int i;
for(i=0;i<n;i++)
{
p.x= lerfloat();
vet_pontos[i][0]=p.x;
p.y= lerfloat();
vet_pontos[i][1]=p.y;
}
return 0;
}
headLer.h
#ifndef FUNCLERN_H_INCLUDED
#define FUNCLERN_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
int func_lerN();
float lerfloat();
float func_lerVetor();
#endif // FUNCLERN_H_INCLUDED
I can not see where I'm going wrong, the lerfloat
function is properly set to headLer.h
.
ps.:a function calls read vector pq it reads coordinates of a vector.
ps2: I already tried to put the prototype of lerfloat
into func_lerVetor
and the error continued.