So i have a CSV file with 61 numbers or so, and depending on the first digit, if its odd or even, it goes into one set or another, but i dont how to read just the first digit of one number and then pass to the next one, while saving that number into one set or another. I have added part of the code.
void lectura(){
float conjunto1[1000],conjunto2[1000];
char temp[1000];
int cont=0,i;
char *numero;
tGeolocalizacion *geo;
const char coma[2] = ";";
char archivo[]= "fichnum.csv";
FILE *pFich;
pFich = fopen (archivo, "r");
if (pFich==NULL)
{
printf ("NO se puede abrir el programa, ERROR\n");
exit(1);
}
cont = 0;
while(!feof(pFich)){
fgets(temp,1000,pFich);
cont++;
}
rewind(pFich);
geo = (tGeolocalizacion*) malloc(cont*sizeof(tGeolocalizacion));
for (i=0; i < cont; i++){
//LEER COMO CHAR Y GUARDAR, DESPUES SE PASA A FLOAT
fgets(temp,1000,pFich);
numero = strtok(temp,coma);
sscanf(numero,"%f", &geo[i].latitud);
numero = strtok(NULL,coma);
sscanf(temp,"%f",&geo[i].longitud);
//This is the part im doing wrong obviously
if (geo[0].latitud%2==0){
geo[i].latitud=conjunto1[i];
}
printf ("f",conjunto1[i]);
if (geo==NULL){
printf ("NO se puede abrir el programa, ERROR\n");
exit(1);
}
printf("el archivo se ha leido correctamente");
}