1

別のプログラムからプログラムを起動しようとしています。

これが図の下のコードです
: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 を使用しています。

4

1 に答える 1

4

スペースを含むパス名を使用しています。これを行うと、すべてがより混乱し、何かを機能させるには、適切な場所で適切なものを引用符で囲む必要があります。

スペースを含まないパス名を使用することをお勧めします。

パス名にスペースを使用してこれを機能させたい場合は、次のようにすることができます。

system("\"c:\\Rasmi Personal\\PERSONAL\\C\\Code Block\\C_Test\\bin\\Debug\\C_Test.exe\"");
于 2012-04-13T06:09:15.370 に答える