How to get the current path in linux with C

1 Answer

0 votes
#include <stdio.h>
#include <unistd.h>

#define PATHLEN 128

int main() {
    char path[PATHLEN];
    
    getcwd(path, PATHLEN);
    
    printf("%s", path);
    
    return 0;
}
 
 
 
 
/*
run:
 
/home/project
 
*/

 



answered Sep 30, 2023 by avibootz

Related questions

1 answer 269 views
1 answer 136 views
1 answer 106 views
1 answer 124 views
1 answer 194 views
...