|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Maybe there is something standard available in C for this. If not, you could try something like this:
Code:
int idx;
char str[STRINGLENGTH];
int numbersfound = 0;
int dotsfound = 0;
for (idx=0; (idx<STRINGLENGTH) && (str[idx]); idx++){
numbersfound += ((str[idx] >= '0') && (str[idx] <= '9'));
dotsfound += (str[idx] == '.');
}
if (numbersfound == STRINGLENGTH)
printf("integer");
else if ((dotsfound == 1) && (numbersfound == STRINGLENGTH-1))
printf("floating point");
else
printf("string");
Ben Vaessen :: Home ::: Launch-IT :: Home |
|
|||
|
Quote:
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help C++ program | statquos | C and C++ | 3 | 06-12-2008 01:23 PM |
| C: how to check if the float is not a char | Cheer | C and C++ | 11 | 04-09-2008 04:16 PM |
| I need help please! | zizimetalique | C and C++ | 5 | 11-17-2007 10:39 PM |
| Please Help With A C Program!! | siren | C and C++ | 7 | 04-17-2007 09:45 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |