diff options
author | Vincent Douillet <vincent@vdouillet.fr> | 2022-12-04 16:47:47 +0100 |
---|---|---|
committer | Vincent Douillet <vincent@vdouillet.fr> | 2022-12-04 16:47:47 +0100 |
commit | 47fd551daab476421411749c5806b3c213cf0a70 (patch) | |
tree | c52d4976f129b43417599d326356b5174dde5983 /input.c | |
parent | 56d350f318f8cf9b580852b123d505845abad84e (diff) |
day 4
Diffstat (limited to 'input.c')
-rw-r--r-- | input.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -72,3 +72,14 @@ void input_str_free(struct input_str* input) { } free(input->lines); } + +char* copy_line(char* line) { + int len = strlen(line); + char* copy = malloc(len * sizeof(char)); + if(copy == NULL) + err(1, "malloc error"); + memset(copy, '\0', len); + strncpy(copy, line, len); + return copy; +} + |