機能 |
ファイルの名前を変更することを表す。 |
||||
---|---|---|---|---|---|
定義 |
#include <stdio.h> int rename ( const char * old, const char * new ); |
||||
引数 |
|
||||
戻り値 |
成功した場合は、0 失敗した場合は、0以外を返す。 |
||||
実装例 |
#include <stdio.h> int main(void) { FILE *fp; int ret; /* ファイルを作成 */ fp = fopen("test.txt", "w"); if (NULL != fp) { printf("\'test.txt\' file was created.\n"); fclose(fp); } /* ファイル名を変更 */ ret = rename("test.txt", "new.txt"); if (0 == ret) { printf("\'test.txt\' file was renamed.\n"); } return 0; } |
||||
実行結果 |
'test.txt' file was created. 'test.txt' file was renamed. |
rename()