#include < stdio.h >
#include < stdlib.h >
#include < string.h >
int main() {
char * str = "5461651 45";
int digiOnly = 1;
for (int i = 0; i < strlen(str); i++) {
if ( * (str + i) < 48 || * (str + i) > 57) {
digiOnly = 0;
break;
}
}
if (digiOnly) printf("Yes digits only are present");
else printf("There are other characters also than digits");
return 0;
}
Check if string contains only digits.
