国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

如何在記事本中做網(wǎng)站鏈接長沙自動seo

如何在記事本中做網(wǎng)站鏈接,長沙自動seo,專業(yè)做網(wǎng)站套餐,重慶做網(wǎng)站那里好目錄 Ⅰ、字符函數(shù)和字符串函數(shù) 1 .strlen 2.strcpy 3.strcat 4.strcmp 5.strncpy 6.strncat 7.strncmp 8.strstr 9.strtok 10.strerror 11.字符函數(shù) 12. 字符轉(zhuǎn)換函數(shù) Ⅱ、內(nèi)存函數(shù) 1 .memcpy 2.memmove 3.memcmp Ⅰ、字符函數(shù)和字符串函數(shù) 1 .strlen 函數(shù)原型:…

目錄

Ⅰ、字符函數(shù)和字符串函數(shù)

????????1?.strlen

????????2.strcpy

????????3.strcat

????????4.strcmp

????????5.strncpy

????????6.strncat

????????7.strncmp

????????8.strstr

????????9.strtok

????????10.strerror

????????11.字符函數(shù)?

????????12. 字符轉(zhuǎn)換函數(shù)

Ⅱ、內(nèi)存函數(shù)

? ? ? ? ?1 .memcpy

????????2.memmove

????????3.memcmp


Ⅰ、字符函數(shù)和字符串函數(shù)

????????1?.strlen

函數(shù)原型:

注意事項(xiàng):

1.字符串以 ?'\0' 作為結(jié)束標(biāo)志 strlen 函數(shù)返回的是在字符串中 '\0' 前面 出現(xiàn)的字符個(gè)數(shù)( 不包含 '\0' )
2.參數(shù)指向的字符串 必須要以 '\0' 結(jié)束 。
3.注意函數(shù)的 返回值 size_t ,是無符號的( 易錯(cuò)
4.學(xué)會 strlen 函數(shù)的模擬實(shí)現(xiàn)

模擬實(shí)現(xiàn):三種方法(計(jì)數(shù)器,遞歸,指針-指針

//模擬實(shí)現(xiàn)strlen
//方法一:計(jì)數(shù)器
size_t my_strlen1(const char* str)
{char* st = str;size_t count = 0;while (*st++){count++;}return count;
}
//方法二:遞歸
size_t my_strlen2(const char* str)
{if (*str == '\0')return 0;return 1 + my_strlen2(++str);//注意這里不能用   后置++
}
//方法三:指針-指針
size_t my_strlen3(const char* str)
{char* st = str;while (*st != '\0'){//printf("%p\n", str);//  從小地址往大地址編址st++;}return st-str;
}

????????2.strcpy

函數(shù)原型:

注意事項(xiàng):

1.Copies the C string pointed by source into the array pointed by destination, including the
terminating null character (and stopping at that point).
2.源字符串 必須以 '\0' 結(jié)束 。
3.會將 源字符串 中的 '\0' 拷貝到 目標(biāo)空間 。
4.目標(biāo) 空間必須足夠大 ,以確保能存放源字符串。
5.目標(biāo) 空間必須可變 。
6.學(xué)會模擬實(shí)現(xiàn)。

模擬實(shí)現(xiàn):

//模擬實(shí)現(xiàn)strcpy
char* my_strcpy(char* dest, const char* src)
{assert(dest && src);char* cur = src; char *re = dest;while (*dest++ = *src++);return re;
}

????????3.strcat

函數(shù)原型:

注意事項(xiàng):

1.Appends a copy of the source string to the destination string. The terminating null character
in destination is overwritten by the first character of source, and a null-character is included
at the end of the new string formed by the concatenation of both in destination.
2.源字符串 必須以 '\0' 結(jié)束 。
3.目標(biāo) 空間 必須有 足夠 的大,能容納下源字符串的內(nèi)容。
4.目標(biāo)空間必須 可修改 。
5.字符串自己給自己追加,如何?不能,可能會 非法訪問

模擬實(shí)現(xiàn):

//模擬實(shí)現(xiàn)strcat
char* my_strcat(char* dest, const char* src)
{assert(dest&&src);char* ret = dest;while (*dest != '\0')dest++;char* sr = src;while (*dest++ = *sr++);return ret;
}

????????4.strcmp

函數(shù)原型:

注意事項(xiàng):

1.This function starts comparing the first character of each string. If they are equal to each
other, it continues with the following pairs until the characters differ or until a terminating
null-character is reached.
標(biāo)準(zhǔn)規(guī)定:
1.第一個(gè)字符串大于第二個(gè)字符串,則返回 大于0 的數(shù)字
2.第一個(gè)字符串等于第二個(gè)字符串,則返回 0
3.第一個(gè)字符串小于第二個(gè)字符串,則返回 小于0 的數(shù)字

模擬實(shí)現(xiàn):

//模擬實(shí)現(xiàn)strcmp
int my_strcmp(const char* str1, const char* str2)
{assert(str1 && str2);while (*str1 == *str2){if (*str1 == '\0')return 0;str1++;str2++;}if (*str1 < *str2)return -1;elsereturn 1;
}

????????5.strncpy

函數(shù)原型:

注意事項(xiàng):

1.Copies the first num characters of source to destination. If the end of the source C string
(which is signaled by a null-character) is found before num characters have been copied,
destination is padded with zeros until a total of num characters have been written to it.
2.拷貝 num個(gè)字符 字符串到 目標(biāo)空間 。
3.如果源字符串的長度 小于num ,則拷貝完源字符串之后,在目標(biāo)的后邊 追加0 ,直到 num 個(gè)

?簡單使用;

//使用strncpy
int main()
{char buf[128] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";char* str = "abcdef";printf("%s\n", strncpy(buf, str,7 ));//沒有超過就是n為多大就拷貝幾個(gè)過去,//n如果超過了字符串的長度后面就進(jìn)行補(bǔ) '\0'return 0;
}

執(zhí)行結(jié)果:

?

????????6.strncat

函數(shù)原型:

注意事項(xiàng):

1.Appends the first num characters of source to destination, plus a terminating null-character.
2.If the length of the C string in source is less than num, only the content up to the terminating null-character is copied
3.如果 空間 不夠,要報(bào)錯(cuò)
4.如果num比源字符串長,則緊追加 NULL之前 的字符

簡單使用:

//使用strncat
int main()
{char buf[128]="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";buf[10] = '\0';		//從第一個(gè)'\0'開始拼接buf[20] = '\0';char* str = "abcdef";printf("%s", strncat(buf, str, 5));return 0;
}

執(zhí)行結(jié)果:

?

????????7.strncmp

函數(shù)原型:

注意事項(xiàng):

比較到出現(xiàn)另個(gè)字符不一樣或者一個(gè)字符串結(jié)束或者num個(gè)字符全部比較完。

簡單使用:

/* strncmp example */
int main()
{char str[][5] = { "R2D2" , "C3PO" , "R2A6" };int n;puts("Looking for R2 astromech droids...");for (n = 0; n < 3; n++)if (strncmp(str[n], "R2xx", 2) == 0){printf("found %s\n", str[n]);}return 0;
}

?執(zhí)行結(jié)果:

????????8.strstr

函數(shù)原型:

注意事項(xiàng):

Returns a poin ter to the first occurrence of str2 in str1, or a null pointer if str2 is not part of
str1.

模擬實(shí)現(xiàn):

//strstr的模擬實(shí)現(xiàn)
char* my_strstr(const char* str1, const char* str2)
{while (*str1){if (*str1 == *str2){char* s1 = str1; char* s2 = str2;while (*s1 && *s2 && (*s1 == *s2)){s1++;s2++;}if (*s2 == '\0')return str1;}str1++;}
}

????????9.strtok

函數(shù)原型:

注意事項(xiàng):

1.sep 參數(shù)是個(gè)字符串,定義了用作 分隔符的字符集合
2.第一個(gè)參數(shù)指定一個(gè)字符串,它包含了 0個(gè)或者多個(gè)由sep字符串中一個(gè)或者多個(gè)分隔符 分割的標(biāo)記。
3.strtok 函數(shù) 找到str中的下一個(gè)標(biāo)記 ,并將其用 \0 結(jié)尾 ,返回一個(gè)指向這個(gè) 標(biāo)記的指針
(注strtok函數(shù)會 改變被操作的字符串 ,所以在使用 strtok 函數(shù)切分的字符串一般都是 臨時(shí)拷貝的內(nèi)容并且可修改 。)
4.strtok 函數(shù)的 第一個(gè)參數(shù)不為 NULL ,函數(shù)將找到 str 中第一個(gè)標(biāo)記, strtok 函數(shù)將 保存它在字符串中的位置
5.strtok 函數(shù)的 第一個(gè)參數(shù)為 NULL ,函數(shù)將在同一個(gè)字符串中被 保存的位置開始 ,查找下一個(gè)標(biāo)記。
6.如果字符串中 不存在更多的標(biāo)記 ,則 返回 NULL 指針 。

簡單使用:

//strtok使用
int main()
{char str[128] = "hyd@qwer.com.cn.edu.com";//注意這里必須是可修改的字符串,常量不能修改char* sep = "@.";char* ret = strtok(str, "@.");printf("%s\n", ret);while(ret=strtok(NULL,sep))printf("%s\n", ret);return 0;
}

執(zhí)行結(jié)果:

?

????????10.strerror

函數(shù)原型:

注意事項(xiàng):

返回錯(cuò)誤碼(errno),所對應(yīng)的錯(cuò)誤信息。

簡單使用:

//使用strerror
int main()
{FILE* fp = fopen("data.txt", "r");if (fp == NULL){//printf("打開失敗:%s\n", strerror(errno));//打印錯(cuò)誤信息perror("打開失敗");//類似于 printf+錯(cuò)誤原因}elseprintf("文件打開成功\n");return 0;
}

執(zhí)行結(jié)果:

????????11.字符函數(shù)?

函數(shù) 如果他的參數(shù)符合下列條件就返回真(非0)
iscntrl ????????任何控制字符(1-31是控制字符,32-127是可打印字符)
isspace ?????空白字符:空格‘ ’,換頁 ‘\f’ ,換行 '\n' ,回車 ‘\r’ ,制表符 '\t' 或者垂直制表符 '\v'
isdigit ????????十進(jìn)制數(shù)字 0~9
isxdigit ??????十六進(jìn)制數(shù)字,包括所有十進(jìn)制數(shù)字,小寫字母a~f,大寫字母 A~F
islower ??????小寫字母a~z
isupper ?????大寫字母A~Z
isalpha? ? ? ?字母a~z A~Z
isalnum? ? ? 字母或者數(shù)字,a~z,A~Z,0~9
ispunct? ? ? ?標(biāo)點(diǎn)符號,任何不屬于數(shù)字或者字母的圖形字符(可打印)
isgraph? ? ? ?任何圖形字符
isprint? ? ? ? ?任何可打印字符,包括圖形字符和空白字符

????????12. 字符轉(zhuǎn)換函數(shù)

int tolower ( int c );
int toupper? ( int c );

簡單使用:

/* isupper example */
#include <stdio.h>
#include <ctype.h>
int main ()
{int i=0;char str[]="Test String.\n";char c;while (str[i]){c=str[i];if (isupper(c)) c=tolower(c);putchar (c);i++;}return 0;
}

?執(zhí)行結(jié)果:

Ⅱ、內(nèi)存函數(shù)

? ? ? ? ?1 .memcpy

函數(shù)原型:

注意事項(xiàng):

1.函數(shù) memcpy source 的位置開始向后復(fù)制 num 個(gè)字節(jié)的數(shù)據(jù)到 destination 的內(nèi)存位置。
2.這個(gè)函數(shù)在遇到 '\0' 的時(shí)候并不會停下來。
3.如果 source destination 有任何的重疊,復(fù)制的結(jié)果都是未定義的。

模擬實(shí)現(xiàn):

//模擬實(shí)現(xiàn)memcpy
char* my_memcpy(void* dest, const void* src,size_t sz)
{assert(dest && src);char* ret = dest;while (sz--){*(char*)dest = *(char*)src;dest = (char*)dest + 1;src = (char*)src + 1;}return ret;
}

????????2.memmove

函數(shù)原型:

注意事項(xiàng):

1.和 memcpy 的差別就是 memmove 函數(shù)處理的源內(nèi)存塊和目標(biāo)內(nèi)存塊是可以重疊的。
2.如果源空間和目標(biāo)空間出現(xiàn)重疊,就得使用 memmove 函數(shù)處理。

模擬實(shí)現(xiàn):

//char* my_memmove(void* dest, const void* src, size_t sz)
{assert(dest && src);char* ret = (char*)dest;if (dest < src){while(sz--){*(char*)dest = *(char*)src;dest = (char*)dest + 1;src = (char*)src + 1;}}else{while (sz--){*((char*)dest + sz) = *((char*)src + sz);}}
}

????????3.memcmp

函數(shù)原型:

注意事項(xiàng);

1.比較從 ptr1 ptr2 指針開始的 num 個(gè)字節(jié)
2.返回值如下:

簡單使用:

int main()
{int arr1[] = { 1,2,3,4,5,6,7 };//01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00//int arr2[] = { 1,2,3,0x11223304 };//01 00 00 00 02 00 00 00 03 00 00 00 04 33 22 11int ret = memcmp(arr1, arr2, 13);printf("%d\n", ret);return 0;
}

執(zhí)行結(jié)果:0?

http://aloenet.com.cn/news/35993.html

相關(guān)文章:

  • 黃石建設(shè)信息網(wǎng)站國內(nèi)網(wǎng)絡(luò)銷售平臺有哪些
  • 公司網(wǎng)站建設(shè)開發(fā)濟(jì)南興田德潤優(yōu)惠嗎推廣平臺排行榜app
  • 行業(yè)網(wǎng)站建設(shè)費(fèi)用百度seo推廣軟件
  • 公司 做網(wǎng)站推廣信息發(fā)布平臺
  • 做網(wǎng)站是什么專業(yè)什么工作百度后臺推廣登錄
  • 做pc端網(wǎng)站要成本么廣告推廣軟件
  • wordpress loading優(yōu)化
  • wordpress手機(jī)版怎么注冊seo站
  • 做設(shè)計(jì)排版除了昵圖網(wǎng)還有什么網(wǎng)站中國新冠疫情最新消息
  • 專業(yè)做網(wǎng)站杭州網(wǎng)站推廣平臺
  • 東營本地網(wǎng)站制作公司品牌策劃與推廣方案
  • ios wordpress 編輯器淄博seo網(wǎng)站推廣
  • 小城鎮(zhèn)建設(shè)的網(wǎng)站谷歌瀏覽器 官網(wǎng)下載
  • 做網(wǎng)站有前途云南seo網(wǎng)絡(luò)優(yōu)化師
  • 學(xué)生做的網(wǎng)站需要備案seo課程多少錢
  • 建設(shè)網(wǎng)站經(jīng)營范圍怎么在百度上添加自己的店鋪地址
  • 網(wǎng)站制作 信科網(wǎng)絡(luò)第三方推廣平臺
  • 打字建站寶愛站官網(wǎng)
  • wordpress阿里百秀全達(dá)seo
  • i深建官方網(wǎng)站怎么做免費(fèi)的網(wǎng)站推廣
  • 織夢 網(wǎng)站欄目管理 很慢小紅書軟文案例
  • 網(wǎng)頁設(shè)計(jì)網(wǎng)站建設(shè)的基本流程關(guān)鍵詞工具有哪些
  • 怎樣在網(wǎng)站上做鏈接站長字體
  • 上海app網(wǎng)站開發(fā)價(jià)值信息發(fā)布平臺推廣有哪些
  • 浙江網(wǎng)站建設(shè)報(bào)價(jià)seo指的是搜索引擎
  • 湖北中牛建設(shè)有限公司網(wǎng)站網(wǎng)站搜索
  • 哪個(gè)網(wǎng)站有ae免費(fèi)模板競價(jià)托管咨詢微競價(jià)
  • 現(xiàn)在幫人做網(wǎng)站賺錢嗎bt種子bt天堂
  • 建設(shè)政府信息網(wǎng)站如何注冊網(wǎng)站平臺
  • 做航空產(chǎn)品的網(wǎng)站有哪些搜索量用什么工具查詢