Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <errno.h>
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <limits.h>
- int main(void){
- char cwd[PATH_MAX];
- if(!getcwd(cwd,sizeof(cwd))) {
- fprintf(stderr,"Errorgetcwd(): %s",strerror(errno));
- exit(EXIT_FAILURE);
- }
- printf("cwd=%s\n",cwd);
- char new_dir[PATH_MAX];
- snprintf(new_dir,sizeof(new_dir),"/tmp/");
- if(chdir(new_dir)==-1){
- fprintf(stderr,"Can'tchdirto'%s':%s\n",
- new_dir,strerror(errno));
- exit(1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement