save serial data to variable?

so what about

           for (int j=indices[i];j<(indices[i+1]-1);j++){
             if (j == 2){
                  char  temp1[] = linea[j+1];
                  lat = atoi(temp);
             }
             if (j == 4){
                  char temp2[] =  linea[j+1];
                  long = atoi(temp2);
             }
             Serial.print(linea[j+1]);

never used atoi before but from what I looked up it seems like that should work. Maybe?