本文介绍了如何使用Chdir()来更改我的工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这是我的代码,我想更改我的工作目录我的代码中有什么问题,还是有其他方法可以更改目录? char str [ 200 ]; scanf( %80 [^ \\ nn],str) ; (chdir(str) 解决方案 我也试试这件事给它分段错误 char str1 [ 400 ]; char str [ 200 ]; char dirc [ 200 ]; if (getcwd(dirc, sizeof (dirc))!= NULL){ scanf( %5 [^ \ r],str); str1 [ 400 ] = sprintf( %s%s,dirc,str); } chdir(str1); This is my code and i want to change my working directory what is the problem in my code or is there is any other way to change directory?char str[200]; scanf("%80[^\r\n]", str); (chdir(str) 解决方案 i also try this thing at it gives segmentation faultchar str1[400]; char str[200]; char dirc[200]; if(getcwd(dirc, sizeof(dirc)) != NULL){ scanf("%5[^\r]", str); str1[400] = sprintf("%s %s", dirc, str); } chdir(str1); 这篇关于如何使用Chdir()来更改我的工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!