"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

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
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!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...