Can't believe my "global" variable question gets so many responses! I have another problem. I have simple function below which check to see if the argument enter at the command line is a valid number. This function work fine with possitive integer, but I want it to accept floating point number as well. The floating point number can include "+" and "-" sign, and decimal point. Thank you in advance! Thomas /******************************************************************** * check_valid_number: this function checks each character in * * string to ensure that it is a valid * * digit. It return 1 if string makes a * * valid number, zero otherwise. * * * * char_string : a string to be tested if it is a valid * * digit * * * * Return : 1 if string makes a valid number, * * zero otherwise. * ********************************************************************/ int check_valid_number(char *char_string) { int count, length; /* count the number of character in the string */ length = strlen(char_string); /* go through each character and check whether it is a valid digit */ for(count = 0; count < length; count++) if (!isdigit(*(char_string + count))) return 0; /* return 1 if it is a valid number */ return 1; } /* end of check_valid_number */ >From: Roman Black >Reply-To: pic microcontroller discussion list >To: PICLIST@MITVMA.MIT.EDU >Subject: Re: [OT]: Beginner C question >Date: Mon, 30 Apr 2001 02:35:13 +1000 > >Mark Benson wrote: > > > > >> Global variables are indeed bad form and should be avoided whenever > > >> possible. > > > >I can see the point here, but again, usually not a problem on a PIC >based > > >project -- ceratinly not any of mine. > > >At the risk of sounding argumentative, surely all >tools are best used by a skilled person. Like a >screwdriver SHOULD be used to turn screws, but I >feel real justified also using one to open a tin of >paint.:o) > >When I worked on a PC programming team my job was >to make the graphics engine and small utilities, and >yes I used globals when they were best and even gotos. >I also made the fastest and smallest C code out of the >group. And it worked well. > >Some carpenters swear by the nail gun and do great >work, other use nothing but glued dowel pins, both >think they are right... > >So especially on a PIC forum where most programs >are small and specialised the university model >of "globals==bad || gotos==bad" must be considered >as just a starting point, not the meaning of life. >I think in all fields the rules you teach an >impressionable student are very different to the >rules an experienced professional lives by. :o) >-Roman > >-- >http://www.piclist.com hint: The PICList is archived three different >ways. See http://www.piclist.com/#archives for details. > > _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.