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 273 views
1 answer 137 views
1 answer 106 views
1 answer 124 views
1 answer 195 views
...