college/Spring-2024/CS-2124/Assignment-1/src/C6.c

23 lines
588 B
C
Raw Normal View History

2024-01-28 22:02:25 -06:00
#include "src.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void c6() {
size_t str_len = strlen(FIRST_NAME);
char *newstr = malloc(str_len + 1);
// strcpy is just calling memcpy under
// the hood
memcpy(newstr, FIRST_NAME, str_len + 1);
solve(6,
"Computes string's length and copies one string into another string",
fmtstr("String: %s, Location %p\nLength: %d\nCopied String: %s, Location: %p", FIRST_NAME, &FIRST_NAME,
str_len, newstr, &newstr));
}
int main() {
print_header();
c6();
return 0;
}