From e8f104fdba00c3ea823863b76d3f1afc52320217 Mon Sep 17 00:00:00 2001 From: Myles Busig Date: Wed, 30 Oct 2024 12:46:37 -0700 Subject: [PATCH] Add problem 6 solutions --- include/p6.h | 7 +++++++ src/main.c | 11 +++++++++++ src/p6.c | 17 +++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 include/p6.h create mode 100644 src/p6.c diff --git a/include/p6.h b/include/p6.h new file mode 100644 index 0000000..ecffba2 --- /dev/null +++ b/include/p6.h @@ -0,0 +1,7 @@ +#ifndef P6_H +#define P6_H + +void str_to_upper(char* str); + +#endif + diff --git a/src/main.c b/src/main.c index e7faee3..c8dc6c4 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,7 @@ #include "p3.h" #include "p4.h" #include "p5.h" +#include "p6.h" void print_int_arr(int* arr, int size) { for (int i = 0; i < size; ++i) { @@ -53,9 +54,19 @@ int main(void) { // Problem 5 printf("Problem 5:\n"); + int num_alphanum = count_alphanumeric("Hello World!!"); printf("Number of alphanumeric characters in \"Hello World!!\": %d\n", num_alphanum); + // Problem 6 + printf("Problem 6:\n"); + + char p6_str[32] = "I have 3$, wow!"; + + printf("\"%s\"\n", p6_str); + str_to_upper(p6_str); + printf("\"%s\"\n", p6_str); + return 0; } diff --git a/src/p6.c b/src/p6.c new file mode 100644 index 0000000..5230420 --- /dev/null +++ b/src/p6.c @@ -0,0 +1,17 @@ +#include "p6.h" + +#define _CRT_SECURE_NO_WARNINGS + +#include + +void str_to_upper(char* str) { + char* current = str; + + while (*current != '\0') { + *current = toupper(*current); + + ++current; + } +} + +