1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【C言語】systemでdirコマンドを実行する win7 32bit

Posted at
C言語
# include <stdio.h>
# include <stdlib.h>

int main (){

    int ret=0;
	char *cmdline="cd C:\\2014 & dir";

    ret=system(cmdline);
	
	if(ret!=0)
	{
	 printf("error ! \n");
	}

 	return 0;
}

環境

OS:windows7 32bit (自作機)
コンパイラ:Borland C++ 5.5.1 for Win32

解説

systemでdirコマンドを実行する。

コンパイルと実行結果

上記ソースをC:\2014\0620\003.cとしてコンパイルして実行する。

C:\2014\0620>bcc32 003.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
003.c:
警告 W8004 003.c 7: 'ret' に代入した値は使われていない(関数 main )
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland

C:\2014\0620>003.exe
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は XXXXXXXXXX です

 C:\2014 のディレクトリ

2014/06/20  23:44    <DIR>          .
2014/06/20  23:44    <DIR>          ..
2014/05/15  22:29    <DIR>          0425
2014/05/14  07:09    <DIR>          0514
2014/05/16  07:22    <DIR>          0515
2014/06/03  07:16    <DIR>          0601
2014/06/08  23:48    <DIR>          0608
2014/06/19  23:45    <DIR>          0619
2014/06/20  23:45    <DIR>          0620
2014/05/14  07:09    <DIR>          java
               0 個のファイル                   0 バイト
              10 個のディレクトリ  17,056,096,256 バイトの空き領域

C:\2014\0620>

関連

【C言語】_popenでdirコマンドを実行する win7 32bit
http://qiita.com/kyoshiro-obj/items/b406f54d82786c2b190a

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?