From f2c9fe3ee5529df44a9388f846fe4a0090c92c97 Mon Sep 17 00:00:00 2001 From: Rachit Bhalla Date: Tue, 20 Oct 2020 10:49:16 +0530 Subject: [PATCH] updated with the suggested changes --- conversions/octal_to_hexadecimal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/conversions/octal_to_hexadecimal.c b/conversions/octal_to_hexadecimal.c index 9ab706c2..6c975810 100644 --- a/conversions/octal_to_hexadecimal.c +++ b/conversions/octal_to_hexadecimal.c @@ -1,4 +1,5 @@ /** + * @file * @brief Octal to hexadecimal conversion by scanning user input * @details * The octalToHexadecimal function take the octal number as long @@ -30,6 +31,7 @@ long octalToDecimal(long octalValue){ /** * @brief Convert octal number to hexadecimal number + * dynamically allocated memory needs to be freed by the calling the function free * @param octalValue is the octal number that needs to be converted * @returns a hexadecimal value as a string after conversion */ @@ -60,13 +62,18 @@ int main() // execute the tests test(); + // get the value of octal number as input int octalValue; printf("Enter an octal number: "); scanf("%d", &octalValue); - // Calling the function octalToHexadecimal + // call the function octalToHexadecimal and print the hexadecimal value char *hexadecimalValue = octalToHexadecimal(octalValue); printf("Equivalent hexadecimal number is: %s", hexadecimalValue); + + // free the memory allocated dynamically in function octalToHexadecimal free(hexadecimalValue); + + // return 0 and exit return 0; }