gpt4 book ai didi

c - 从 C 中的另一个程序执行一个程序

转载 作者:可可西里 更新时间:2023-11-01 11:21:07 25 4
gpt4 key购买 nike

我正在尝试从另一个程序启动一个程序。

下面是代码
图:1

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
int main()
{
printf("Before Execution \n");
system("c:\\Rasmi Personal\\PERSONAL\\C\\Code Block\\C_Test\\bin\\Debug\\C_Test.exe");
printf("\nAfter Execution \n");
return 0;
}

在c:\Rasmi Personal\PERSONAL\C\Code Block\C_Test\bin\Debug\C_Test项目中包含的代码是

图 2:

#include <stdio.h>
int main()
{
int x = 10;
while( x --> 0 ) // x goes to 0
{
printf("%d\n", x);
} return 0;
}

但是在执行第一个程序(图 1)时,输出如下。

Before Execution
'c:\Rasmi' is not recognized as an internal or external command,
operable program or batch file.

After Execution

请帮我解决这个问题。

PS:- 我在 Windows XP 中使用 CODE::BLOCKS。

最佳答案

您正在使用其中包含空格的路径名。当您这样做时,一切都会变得更加困惑,并且您必须在正确的地方为正确的事物添加引号才能使任何事物正常工作。

我建议使用不带空格的路径名。

如果您仍想尝试使用路径名中的空格来实现这一点,可以使用以下方法:

system("\"c:\\Rasmi Personal\\PERSONAL\\C\\Code Block\\C_Test\\bin\\Debug\\C_Test.exe\"");

关于c - 从 C 中的另一个程序执行一个程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10136015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com