C言語-標準ライブラリ
 入出力関数 文字処理関数 文字列処理関数 数値演算関数 その他の関数 標準ライブラリの目次

ANSI C標準ライブラリ関数一覧

その他

abs() : 整数nの絶対値を計算する。
#include <stdlib.h>
int abs(int n);

div() : numeratorをdenominatorで割った商と余りを除算する。
#include <stdlib.h>
div_t div(int numerator,int denominator);

返却値
typedef struct {
    int quot;     /* 商 */
    int rem;      /* 余り */
} div_t;

labs() : long型整数nの絶対値を計算する。
#include <stdlib.h>
long labs(long n);

ldiv() : numeratorをdenominatorで割った商と余りを除算する。
#include <stdlib.h>
ldiv_t ldiv(long numerator,long denominator);

返却値
typedef struct {
    long quot;     /* 商 */
    long rem;      /* 余り */
} ldiv_t;

atoi() : 文字列stringを整数に変換する。
#include <stdlib.h>
int atoi(const char *string);

strtol() : 文字列sptrをbase進数の文字列としてlong型の数値に変換する。
#include <stdlib.h>
long strtol(const char *sptr,char **tailptr,int base);

atol() : 文字列stringをlong型の整数に変換する。
#include <stdlib.h>
long int atol(const char *string);

strtoul() : 文字列をsptrをbase進数の文字列としてunsigned long型の数値に変換する。
#include <stdlib.h>
unsigned long int strtoul(const char *sptr,char **tailptr,int base);

atof() : 文字列stringを浮動小数に変換する。
#include <stdlib.h>
double atof(const char *string);

strtod() : 文字列stringを浮動小数点に変換する。
#include <stdlib.h>
double strtod(const char *string,char **tailptr);

system() : 文字列programをオペレーティングシステムのコマンドとして実行する。
#include <stdlib.h>
int system(const char *program);

getenv() : 環境変数variableを読み込む。
#include <stdlib.h>
char *getenv(const char *variable);

返却値
 環境変数variableの値を返す。もし、variableという変数が見つからなかったときはNULLを返す。

exit() : 後始末をしてプログラムを終了する。
#include <stdlib.h>
void exit(int status);

abort() : プログラムを直ちに終了する。
#include <stdlib.h>
void abort(void)

atexit() : プログラム終了の際に実行する関数を登録する。
#include <stdlib.h>
int atexit(void (*function)(void));

返却値
 登録できた場合は0を返し、登録できなかった場合は0以外を返す。

rand() : 疑似乱数を発生する。
#include <stdlib.h>
int rand(void);

srand() : 疑似乱数発生ルーチンにシードseedを与える。
#include <stdlib.h>
void srand(unsigned int seed);

calloc() : 動的にsizeバイトをcount個分メモリを割り当て,0に初期化する。
#include <stdlib.h>
void *calloc(size_t count,size_t size);

返却値
 確保されたメモリ・ブロックへのポインタを返す。

malloc() : 動的メモリ(dynamic memory)をsizeバイト分割り当てる。
#include <stdlib.h>
void *malloc(size_t size);

返却値
 確保されたメモリ・ブロックへのポインタを返す。

realloc() : 動的メモリを再割り当てする。
#include <stdlib.h>
void *realloc(void *ptr,size_t size);

返却値
 再割り当てされたメモリ・ブロックへのポインタを返す。

free() : 動的に割り当てたメモリを解放する。
#include <stdlib.h>
void free(void *ptr);

qsort() : 配列をソートする。
#include <stdlib.h>
void qsort(void *array,size_t number,size_t size,int (*comparison)(const void *,const void *));

bsearch() : 配列内のバイナリサーチする。
#include <stdlib.h>
void *bsearch(const void *item,const void *array,size_t number,size_t size,int (*comparison)(const void *,const void *));

返却値
 見つかった要素のアドレスを返します。見つからなかったときはNULLを返す。

difftime() : 2つの時刻の差を計算する。
#include <time.h>
double difftime(time_t newtime,time_t oldtime);

返却値
 double型で表現された秒単位の差を返す。

clock() : プログラム起動から現在までの時間を得る。
#include <time.h>
clock_t clock(void);

返却値
 現在の時刻を1970年1月1日午前0時0分0秒からの通算秒数で返す。

asctime() : 日時文字列に変換する。
#include <time.h>
char *asctime(const struct tm *timestruct);
struct tm {
    int tm_sec;   /* 秒(0-59) */
    int tm_min;   /* 分(0-59) */
    int tm_hour;  /* 時(0-23) */
    int tm_mday;  /* 日(1-31) */
    int tm_mon;   /* 月(0-11) */
    int tm_year;  /* 西暦年-1900 */
    int tm_wday;  /* 曜日(0-6) */
    int tm_yday;  /* 通算日数(0-365) */
    int tm_isdst; /* サマータイムフラグ */
};

返却値
 struct tm型の時刻データを、文字列に変換する。その文字列のアドレスを返す。

mktime() : struct tm型の時刻データ(broken-down time)を暦時間time_t型に変換する。
#include <time.h>
time_t mktime(struct tm *timeptr);

返却値
 変換された時間を返す。

time() : 現在の暦時間を得る。time_t型はlong型と同じ。
#include <time.h>
time_t time(time_t *tp);

返却値
 現在の時刻を1970年1月1日午前0時0分0秒からの通算秒数で返す。

localtime() : 暦時間time_t型を現地時間struct tm型に変換する。
#include <time.h>
struct tm *localtime(const time_t *timeptr);

返却値
 変換された時間を返す。

gmtime() : 暦時間を時刻を現地時間でなく世界標準時UTCに変換する。
#include <time.h>
struct tm *gmtime(const time_t *caltime);

返却値
 変換された時間を返す。

ctime() : 暦時間time_t型を文字列に変換する。
#include <time.h>
char *ctime(const time_t *timeptr);

返却値
 変換された文字列のアドレスを返す。

strftime() : ロケール固有の時刻を表示形式formatにしたがって変換する。
#include <time.h>
size_t strftime(char *string,size_t maxinum,const char *format,const struct tm *brokentime);

返却値
stringに書込まれた文字数(ナル文字は含まない)を返す。maxinum 文字以上が生成されたときには0を返す。

signal() : シグナルが検出された場合の処理を設定する。
#include <signal.h>
void (*signal(int signame,void (*function)(int)))(int);

raise() : シグナルを送る。
#include <signal.h>
int raise(int signal);

返却値
 成功すると0を返す。失敗するとerrnoをセットして0以外の値を返す。

setjmp(), longjmp() : 大域ジャンプする。
#include <setjmp.h>
void setjmp(jmp_buf environment);
void longjmp(jmp_buf environment,int rval);


 入出力関数 文字処理関数 文字列処理関数 数値演算関数 その他の関数 標準ライブラリの目次
Copyright © 2001 Hiroshi Masuda 

 

 


setlocale() : プログラムのロケール情報を設定し,検索する。
#include <locale.h>
char *setlocale(int portion,const char *locale);

返却値

localeconv() : 構造体lconvの初期化。
#include <locale.h>
struct lconv *localeconv(void);

返却値

mblen() : マルチバイト文字の文字列の長さを得る。
#include <stdlib.h>
int mblen(const char *address,size_t number);

mbstowcs() : マルチバイト文字の文字列をwide文字の文字列に変換する。
#include <stdlib.h>

mbtowc() : マルチバイト文字をwide文字に変換する。
#include <stdlib.h>
int mbtowc(wchar_t *charptr,const char *address,size_t number);

wcstombs() : wide文字の列をマルチバイト文字列に変換する。
#include <stdlib.h>
size_t wcstombs(char *multibyte,const wchar_t *widechar,size_t number);

wctomb() : wide文字をマルチバイト文字に変換する。
#include <stdlib.h>
int wctomb(char *string,wchar_t widecharacter);


 

 

inserted by FC2 system