1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include "log_macros.h"

// This is from office hours on Mon 2/20/2023

int main(int argc, char* argv[]) {

    // This is not doing the assignment, but it is closely related to part of HW09.

    char s[] = "abc";
    log_str(s);

    int s_len = 4;  // we could have found this in a number of ways.
    char s_copy[4];  // will be unitialized in for loop below

    // This is what memcpy(…) does.
    for(int i = 0; i < s_len; i++) {
        s_copy[i] = s[i];
    }

    log_str(s_copy);

    // memcpy(…) is not required or necessary for HW09.  It is allowed only because there is no
    // good reason to say no.
    
    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2023 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.