個人記事本

2021-07-14 14:42:50 字數 1229 閱讀 6224

size_t strlen(const char *s);

the strlen() function calculates the length of the string s, excluding**(不包括)** the terminating null byte (『\0』).

計算長度時,不包括末尾的結束符』\0』

但是,換行符』\n』要計算在內

char *fgets(char *buff, int size, file *stream);
man手冊:

fgets() reads in at most one less thansizecharacters from stream

and stores them into the buffer pointed to bys. reading stops after an

eof or a newline. if a newline is read, it is stored into the buffer.

a terminating null byte (『\0』) is stored after the last character in the buffer.

char buff[buffsize] = ;
char buf[5];

fgets(buf, sizeof(buf), stdin);

printf("buf= %s", buf);

printf("strlen(buf)= %d.", strlen(buf));

如果從鍵盤輸入:

***x5***
那麼執行結果為:

buf= ***xstrlen(buf)= 4

//注意,這裡沒有換行哦,因為fgets截斷了stdin,只取了前四個x,最後一位用結束符'\0'補齊,而strlen不把結束符計算在內,因此為4.

char buf[5];

while(fgets(buf, sizeof(buf), stdin))

記事本 陳慧琳

翻開隨身攜帶的記事本 寫著許多事都是關於你 你討厭被冷落 習慣被守候 寂寞才找我 我看見自己寫下的心情 把自己放在卑微的後頭 等你等太久 想你淚會流 而幸福快樂是什麼 愛的痛了 痛的哭了 哭的累了 日記本裡頁頁執著 記載著你的好 像上癮的毒藥 它反覆騙著我 愛的痛了 痛的哭了 哭的累了 矛盾心裡總是...

記事本程式

anchor 控制項與容器周圍的距離保持不變 dock 定義容器要停靠到哪一邊,重要的乙個是fill填充 using system using system.collections.generic using system.componentmodel using system.data using...

記事本編碼格式

以下為自己概括 記事本編碼格式 1 每個字元都是使用乙個編碼來表示的,而每個字元究竟使用哪個編碼代表,要取決於使用哪個字符集 charset 開始只有一種字符集,即ansi的 ascii字符集,用 7bits表示乙個字元,能表示 128個字元。隨後進行拓展,使用 8bits表示乙個字元,能表示 25...