I'm developing a function to determine if a user has entered a number or characters.
Here's the code for that:
Code:
#include <stdio.h>
#include <string.h>
#include <stdint.h>
int main() {
int8_t ProgramCounter, SecondaryCounter, CharacterDetect;
char Numbers[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
char UserInput[64];
printf("Enter some numbers and characters.\n");
fgets(UserInput, 64, stdin);
for(ProgramCounter = 0; ProgramCounter < strlen(UserInput); ProgramCounter++)
for(SecondaryCounter = 0; SecondaryCounter < 10; SecondaryCounter++)
if(UserInput[ProgramCounter] == Numbers[SecondaryCounter])
printf("Number found at UserInput index: %d\n", ProgramCounter);
return 0;
}