c - IsDouble function prototype syntax error & warning (data definition has no type or storage class) -


been playing around c trying parse csv file.

right i'm trying implement function check or not string double can convert it. i'm having problems in .h file getting "syntax error before bool" , "data definition has no type or storage class"

#ifndef msgr_h #define msgr_h  #include <stdio.h> #include <stdlib.h>  typedef struct entry  {     char *str;     int ival; } entry;  int numrows(char filename[]); int numcolumns(char filename[]); void tokenizeline(int x; int y; char currentlinestr[], entry etable[x][y], int yindex, int x, int y); *** bool isdouble(const char *str);*** (problem supposedly here) #endif 

below function itself.

bool isdouble(const char *str) {  char *endptr = 0;  bool flag = true;  strtod(str, &endptr);   if(*endptr != '\0' || endptr == str);             flag = false;  return flag; } 

appreciate , input.

there no bool in c unless use @ least c99 , include <stdbool.h>.

common practice: return int, 0 evaluates false, else (normally 1) true when used boolean.

code:

int isdouble(const char *str) {     char *endptr = 0;     strtod(str, &endptr);      if(*endptr != '\0' || endptr == str)     {         return 0;     }     return 1; } 

(there superfluous semicolon ...)


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -