diff options
| author | nasrlol <nsrddyn@gmail.com> | 2025-02-18 22:56:36 +0100 |
|---|---|---|
| committer | nasrlol <nsrddyn@gmail.com> | 2025-02-18 22:56:36 +0100 |
| commit | 3960ffc393a97a26805f7a2e9e98f3125ae0f20d (patch) | |
| tree | 97fdb18a5e0d695c97e75f43f492aaf3f09ad2ad /main.c | |
| parent | 6d0a41b2c3400ffc2d98edc0ea727e53760b2b7b (diff) | |
these are my curent findings on the getcwd command from the unistd.h library
Signed-off-by: nasrlol <nsrddyn@gmail.com>
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -106,6 +106,19 @@ void clear() { printf("\033[3J"); } +char *print_cdirectory() { + char *current_working_directory = getcwd(NULL, 0); + /* getcwd() command already allocates malloc for the path that should be returned, + to do: should I free it when finished or not?/ + so what I understand from the documentation, you should only free it when actually setting an exact size + but when keeping the max size to 0 and relying on the malloc there is no need for it + not sure though + should rely on further debugging + */ + + return current_working_directory; +} + void change_directory(const char *path) { if (path == NULL) { printf("No path found\n"); |
