附加到char * [英] Append to char *
问题描述
我想递归强制清空并删除一个目录。作为
,我想附加char *。
这是代码:
char * directory =" Directory";
char * command =" rm -rf";
如何将两者追加到: rm -rf目录???
在此之后,我想做系统命令:
if(system(command) == 0)
{
printf(成功删除目录\ n);
}
>
谢谢,
Marcia
Hi,
I would like to recursively force to empty and delete a directory. As
such I would like to append the char *.
Here is the code:
char * directory = "Directory";
char * command = "rm -rf ";
How can I append the two to get: "rm -rf Directory"???
Following this, I would like to do the system command:
if(system(command) == 0)
{
printf("Successfully removed directory\n");
}
Thanks,
Marcia
推荐答案
Marcia Hon写道:
Marcia Hon wrote:
char * directory =" Directory";
char * command =" rm -rf";
如何将两者附加到:rm -rf目录???
char * directory = "Directory";
char * command = "rm -rf ";
How can I append the two to get: "rm -rf Directory"???
char命令[FILENAME_MAX + sizeof" rm -rf"] =" rm -rf";
strcat(命令,目录);
-
Rich ard Heathfield: bi****@eton.powernet.co.uk
Usenet是一个奇怪的地方。 - Dennis M Ritchie,1999年7月29日。
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K& R答案,C书等:< a rel =nofollowhref =http://users.powernet.co.uk/etontarget =_ blank> http://users.powernet.co.uk/eton
char command[FILENAME_MAX + sizeof "rm -rf "] = "rm -rf ";
strcat(command, directory);
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
只需包含< string.h>头文件,并使用strcat()功能:
char * directory =" Directory";
char * command =" rm -rf";
strcat(命令,目录);
system(命令);
" Marcia Hon" <马******** @ hotmail.com> écritdansle message de news:
52 ************************* @ posting.google.com ...
Just include <string.h> header file, and use "strcat()" function:
char * directory = "Directory";
char * command = "rm -rf ";
strcat(command,directory);
system(command);
"Marcia Hon" <Ma********@hotmail.com> a écrit dans le message de news:
52*************************@posting.google.com...
我想递归强制清空并删除一个目录。如此
我想附加char *。
这是代码:
char * directory =" Directory" ;;
char * command =" rm -rf";
如何将两者附加到:rm -rf目录???
在此之后,我想做系统命令:
if(system(command)== 0)
{/> printf(成功删除目录\ n);
}
谢谢,
Marcia
Hi,
I would like to recursively force to empty and delete a directory. As
such I would like to append the char *.
Here is the code:
char * directory = "Directory";
char * command = "rm -rf ";
How can I append the two to get: "rm -rf Directory"???
Following this, I would like to do the system command:
if(system(command) == 0)
{
printf("Successfully removed directory\n");
}
Thanks,
Marcia
Duff写道:
Duff wrote:
只需包含< string.h>头文件,并使用strcat()功能:
char * directory =" Directory";
char * command =" rm -rf" ;;
strcat(command,directory);
system(command);
Just include <string.h> header file, and use "strcat()" function:
char * directory = "Directory";
char * command = "rm -rf ";
strcat(command,directory);
system(command);
无论如何,这是让恶魔飞出你鼻子的好方法......
/ J
That''s a pretty good way to make demons fly out your nose, anyway...
/J
这篇关于附加到char *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!