Add problem 6 solutions

This commit is contained in:
Madeline Busig 2024-10-30 12:46:37 -07:00
parent 26a4446341
commit 73983c2c6f
3 changed files with 35 additions and 0 deletions

7
include/p6.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef P6_H
#define P6_H
void str_to_upper(char* str);
#endif

View File

@ -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;
}

17
src/p6.c Normal file
View File

@ -0,0 +1,17 @@
#include "p6.h"
#define _CRT_SECURE_NO_WARNINGS
#include <ctype.h>
void str_to_upper(char* str) {
char* current = str;
while (*current != '\0') {
*current = toupper(*current);
++current;
}
}