|
|
| TopPage > C言語関係 > C言語関係[01] |
| データ型 | bitサイズ | Range |
| unsigned char | 8 | 0 <= value <= 255 |
| char | 8 | -128 <= value <= 127 |
| short int | 16 | -32,768 <= value <= 32,767 |
| unsigned int | 32 | 0 <= value <= 4,294,967,295 |
| int | 32 | -2,147,483,648 <= value <= 2,147,483,647 |
| unsigned long | 32 | 0 <= value <= 4,294,967,295 |
| enum | 32 | -2,147,483,648 <= value <= 2,147,483,647 |
| long | 32 | -2,147,483,648 <= value <= 2,147,483,647 |
| float | 32 | 1.18*10^-38 <= value <= 3.4*10^38 |
| double | 64 | 2.23*10^-308 <= value <= 1.79*10^308 |
| long double | 80 | 3.37*10^4932 <= value <= 1.18*10^4932 |
/* exec_child.c */ #include |
|
system()を利用した実行 exec_test00.c |
fork(),execl(),wait()を利用した実行 exex_test01.c |
fork(),execv(),wait()を利用した実行 exex_test02.c |
|||
|
|
|
|||
| これを実行すると | これを実行すると | これを実行すると | |||
|
|
|
|||
|
外部プログラムの戻り値は、使えないが 実行のみの記述が簡単。 |
外部プログラムへの引数渡しを文字列で 個別に与えることができる。 WEXITSTATUS() で外部プログラムの戻り値を 得ることができる。 でも、なんか、exec_child内部で処理した引数が 変だ。 なぜ?? |
外部プログラムへの引数渡しが文字列リスト char *const argv[]で与えることができる。 WEXITSTATUS() で外部プログラムの戻り値を 得ることができる。 これも引数が。。。そうゆうことか。。。 |
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
////////////////////////////////////////////////////////////////////////////////
main(int argc, char *argv[])
{
struct stat file_stat;
if ( stat( argv[1], &file_stat ) != -1 )
{
printf("path :%s\n",argv[1]);
printf("Device ID :major-%d minor-%d\n",major(file_stat.st_dev), minor(file_stat.st_dev) );
printf("inode :%d\n",file_stat.st_ino );
printf("access mode :%o\n",file_stat.st_mode );
printf("hard link num :%d\n",file_stat.st_nlink );
printf("user ID :%d\n",file_stat.st_uid );
printf("group ID :%d\n",file_stat.st_gid );
printf("Device ID(sp) :major-%d minor-%d\n",major(file_stat.st_rdev),minor(file_stat.st_rdev) );
printf("File size(Byte) :%d\n",file_stat.st_size );
printf("Block size(on system):%d\n",file_stat.st_blksize );
printf("Block size :%d\n",file_stat.st_blocks );
printf("last access time :%s",ctime(&file_stat.st_atime) );
printf("last modify time :%s",ctime(&file_stat.st_mtime) );
printf("last change time :%s",ctime(&file_stat.st_ctime) );
}
}
///////////////////////////////////////EOF//////////////////////////////////////
|
#include <stdio.h>
#include <stdlib.h>
main()
{
printf("H O M E :[%s]\n",getenv("HOME"));
}
///////////////////////////////////////EOF//////////////////////////////////////
|
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
main()
{
DIR *dirp;
if ( (dirp = opendir("./sample_directory")) == NULL )
{
switch ( errno )
{
// rwxのrが設定されていない場合のみ。wxは関係ないみたい
case EACCES :
printf("ディレクトリは、存在しますがアクセス権限がありません。\n");
break;
case EMFILE :
printf("プロセスが使用中のファイルディスクリプタが多すぎます。\n");
break;
case ENFILE :
printf("システムでオープンされているファイルが多すぎます。\n");
break;
case ENOENT :
printf("ディレクトリが存在しないか、名前が空の文字列です。\n");
break;
case ENOMEM :
printf("命令するのに充分なメモリがありません。\n");
break;
case ENOTDIR :
printf("指定された名前は、ディレクトリではありません。\n");
break;
default :
printf("対応するerrnoがありませんがErrorです。\n");
break;
}
}
else
{
close(dirp);
printf("指定したディレクトリは、既に存在しアクセス可能です。\n");
}
}
///////////////////////////////////////EOF//////////////////////////////////////
|
| TopPage > C言語関係 > C言語関係[01] |