[previous] MISRA-C:2004  Rule  20.10:  (Required) [next] The library functions atof, atoi and atol from library <stdlib.h> shall not be used.
These functions have undefined behaviour associated with them when the string cannot be converted.

Example Code:


/* PRQA S 2983,3203 ++ */

#include <stdlib.h>
#include "misra.h"
#include "m2cmex.h"

extern S16 test_2010( void )
{
   F64 d;
   S16 i;
   S32 l;

   d = atof( "12.34" );          /* MISRA Violation */
   i = atoi( "3456" );           /* MISRA Violation */
   l = atol( "12345678" );       /* MISRA Violation */

   return 0;
}


QAC messages that encompass this guideline:

5125 The library functions atof, atoi and atol from library <stdlib.h> shall not be used.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents