"Array subscript is not an integer" error when using atof()

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear freaks

 

I was converting NMEA gps coordinates to floats for further calculations.My code is as follows.But whenever compiling,it is returning "Array subscript is not an integer".Please help!!

 

float latf,longf;

 

char lati[15];
char longi[15];

 

latf = atof[lati];
longf = atof[longi];

 

I am using AS7.Also same is happening when trying to use strtod();

This topic has a solution.
Last Edited: Tue. Mar 14, 2017 - 11:21 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Solved...was happening for wrong braces[].cheeky

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Put it in the proper code format to see clearly:

 

latf = atof[lati];
longf = atof[longi];

 

You need round brackets - aka "parentheses" - not square brackets!!

 

parentheses are for function calls; square brackets are for indexing.

 

 

#parentheses #brackets #braces

Last Edited: Mon. Mar 20, 2017 - 09:05 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SHARANYADAS wrote:
Solved...was happening for wrong braces[].cheeky 

 

"braces" are the curly ones - different from both parentheses and square brackets!