From fa12fdef2abc59d466c6dcd66f24080a86aa3a69 Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Thu, 2 Feb 2023 10:50:37 +0100 Subject: [PATCH] Implementation of function everyCharacterIsDigit(). --- src/stringManipulation.c | 20 ++++++++++++++++++-- src/stringManipulation.h | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/stringManipulation.c b/src/stringManipulation.c index 37c9f89..84eea0a 100644 --- a/src/stringManipulation.c +++ b/src/stringManipulation.c @@ -67,17 +67,33 @@ unsigned int power(unsigned int base, unsigned int exponent){ } } +bool everyCharacterIsDigit(char *string) +{ + bool onlyDigits = true; + for(int i=0;*(string+i)!='\0';++i){ + if(*(string+i)<'0'||*(string+i)>'9'){ + onlyDigits = false; + break; + } + } + return onlyDigits; +} + + unsigned int toUnsignedInteger(char *ID) { + if(everyCharacterIsDigit(ID)){ unsigned int result = 0; int IDLength = strlen(ID); for(int i=0, j = IDLength - 1;i #include #include -#include +#include char *stringConcatenation(char *, char *); char *to_string(int); char *generateCheckString(unsigned int, char *); unsigned int toUnsignedInteger(char *); unsigned int power(unsigned int, unsigned int); +bool everyCharacterIsDigit(char *);