A bit confused per normal. Both of the isdigits should be pointing to the same place regardless if it's using [0] to call the array or [m] which is currently set to 0? Why would they be giving me different results? When I compile and run I get the following for the following inputs:
if I put in 1 they both return 1
if I put in 1andaword (isdigit(s[m])) returns a 0 but (isdigit(s[0])) returns a 1. same if I put 1 andawordwithaspacebetween?
Code:int main (void) { int charcount = 0; int integers = 0; int integers2 = 0; int m = 0; char s[] = {0}; int len = 0; printf("Enter a string:\n"); scanf("%256[^\n]", s); len = strlen(s); if (isdigit(s[m])) { integers = integers + 1; } printf("there are %d integers in your string\n\n", integers); if (isdigit(s[0])) { integers2 = integers2 + 1; } printf("there are %d integers in your string", integers2); return 0; }