Originally Posted by
Axel
i have an array of numbers i.e.: 9 2938932 29382332 what i want to do is remove these spaces so it can be joined. i have tried... isdigit(atoi(temp)) == 0) basically in this line of code temp is a char array in which i stored each individual number and apply atoi to convert it to a digit so i can use it with isdigit. Unfortunately it doesn't seem to work. When i put a space in the array i.e. ' ' it prints out a 0. any ideas?
You shouldn't be converting the strings to integers and then passing the integers to isdigit. I can see why you might think that if you've seen something like this:
Code:
#include <ctype.h>
int isdigit(int c);
but the parameter isan integer whose value is representable as an unsigned char, or the value of the macro EOF
You should just loop over the string passing each character to isdigit:
Code:
for (i=0; i<strlen(temp); i++) {
if (!isdigit(temp[i])) {
/* this is one of those spaces */
}
}