「文字列処理関数(string.h)」の編集履歴(バックアップ)一覧はこちら

文字列処理関数(string.h)」(2010/06/10 (木) 23:57:34) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

**文字列処理関数 #include <string.h>が必要となります。 メモリの中で特定の文字列を探す memchr(const *pbuf, int c, size_t MaxCount) 引数 pbuf:文字を探すメモリバッファのポインタ c:探す文字 MaxCount:文字数 戻り値:文字があればその文字のポインタ,なければNULL #region(close, プログラム例) #include <stdio.h> #include <string.h> int main(){ char pbuf[80]="Hello World!"; char c; int flag; printf("文字列 -> %s \n",pbuf); printf("探したい1文字入力:"); scanf("%c", &c); if( memchr( pbuf , c , strlen(pbuf) ) != NULL) printf("%sの中に%cは存在します \n" , pbuf , c); else printf("%sの中に%cは存在しません \n" , pbuf , c); return 0; } #endregion 2つの文字列を連結する strcat(char *dest, const char *source) 引数 dest:先頭の文字列 source:後ろに連結する文字列 戻り値:連結された後の文字列destのポインタ #region(close, プログラム例) #include <stdio.h> #include <string.h> int main(){ char str1[80] = "Hello"; char str2[] = "World!"; strcat(str1,str2); printf("%s \n", str1 ); } 実行結果 HelloWorld! #endregion 文字列の長さを求める strlen(const char *str) 引数 str:長さを求めたい文字列 戻り値:文字数 #region(close, プログラム例) #include <stdio.h> #include <string.h> int main(){ char str[80]; printf("文字列を入力してください:"); scanf("%s", str); printf("入力した文字列の文字数は%dです \n", strlen(str) ); return 0; } #endregion //#region(close, プログラム例) //#endregion ...

表示オプション

横に並べて表示:
変化行の前後のみ表示:
目安箱バナー