中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

做網(wǎng)站需要什么許可證推廣平臺哪個效果最好

做網(wǎng)站需要什么許可證,推廣平臺哪個效果最好,商務網(wǎng)站建設流程步驟,網(wǎng)站 郵件系統(tǒ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. 字符轉換函數(shù) Ⅱ、內存函數(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. 字符轉換函數(shù)

Ⅱ、內存函數(shù)

? ? ? ? ?1 .memcpy

????????2.memmove

????????3.memcmp


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

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

函數(shù)原型:

注意事項:

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

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

//模擬實現(xiàn)strlen
//方法一:計數(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ù)原型:

注意事項:

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' 結束
3.會將 源字符串 中的 '\0' 拷貝到 目標空間 。
4.目標 空間必須足夠大 ,以確保能存放源字符串。
5.目標 空間必須可變 。
6.學會模擬實現(xiàn)。

模擬實現(xiàn):

//模擬實現(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ù)原型:

注意事項:

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' 結束 。
3.目標 空間 必須有 足夠 的大,能容納下源字符串的內容。
4.目標空間必須 可修改
5.字符串自己給自己追加,如何?不能,可能會 非法訪問

模擬實現(xiàn):

//模擬實現(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ù)原型:

注意事項:

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.
標準規(guī)定:
1.第一個字符串大于第二個字符串,則返回 大于0 的數(shù)字
2.第一個字符串等于第二個字符串,則返回 0
3.第一個字符串小于第二個字符串,則返回 小于0 的數(shù)字

模擬實現(xiàn):

//模擬實現(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ù)原型:

注意事項:

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個字符 字符串到 目標空間 。
3.如果源字符串的長度 小于num ,則拷貝完源字符串之后,在目標的后邊 追加0 ,直到 num

?簡單使用;

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

執(zhí)行結果:

?

????????6.strncat

函數(shù)原型:

注意事項:

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.如果 空間 不夠,要報錯
4.如果num比源字符串長,則緊追加 NULL之前 的字符

簡單使用:

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

執(zhí)行結果:

?

????????7.strncmp

函數(shù)原型:

注意事項:

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

簡單使用:

/* 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í)行結果:

????????8.strstr

函數(shù)原型:

注意事項:

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

模擬實現(xiàn):

//strstr的模擬實現(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ù)原型:

注意事項:

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

?

????????10.strerror

函數(shù)原型:

注意事項:

返回錯誤碼(errno),所對應的錯誤信息。

簡單使用:

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

執(zhí)行結果:

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

函數(shù) 如果他的參數(shù)符合下列條件就返回真(非0)
iscntrl ????????任何控制字符(1-31是控制字符,32-127是可打印字符)
isspace ?????空白字符:空格‘ ’,換頁 ‘\f’ ,換行 '\n' ,回車 ‘\r’ ,制表符 '\t' 或者垂直制表符 '\v'
isdigit ????????十進制數(shù)字 0~9
isxdigit ??????十六進制數(shù)字,包括所有十進制數(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? ? ? ?標點符號,任何不屬于數(shù)字或者字母的圖形字符(可打印)
isgraph? ? ? ?任何圖形字符
isprint? ? ? ? ?任何可打印字符,包括圖形字符和空白字符

????????12. 字符轉換函數(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í)行結果:

Ⅱ、內存函數(shù)

? ? ? ? ?1 .memcpy

函數(shù)原型:

注意事項:

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

模擬實現(xiàn):

//模擬實現(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ù)原型:

注意事項:

1.和 memcpy 的差別就是 memmove 函數(shù)處理的源內存塊和目標內存塊是可以重疊的。
2.如果源空間和目標空間出現(xiàn)重疊,就得使用 memmove 函數(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ù)原型:

注意事項;

1.比較從 ptr1 ptr2 指針開始的 num 個字節(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í)行結果:0?

http://www.risenshineclean.com/news/4110.html

相關文章:

  • 建一個大型網(wǎng)站需要多少錢網(wǎng)絡服務器價格
  • 接私活做預算的網(wǎng)站百度競價推廣開戶費用
  • 無錫網(wǎng)站設計無錫網(wǎng)站建設廣州網(wǎng)站排名專業(yè)樂云seo
  • 公司設計資質seo搜索引擎優(yōu)化推廣
  • 網(wǎng)站制作費用及后期運營seo推廣優(yōu)化官網(wǎng)
  • 網(wǎng)站開發(fā)項目教程湖北seo服務
  • 學做衣服上什么網(wǎng)站小紅書seo排名規(guī)則
  • 網(wǎng)站公司開發(fā)網(wǎng)絡推廣員的前景
  • 做房地產(chǎn)網(wǎng)站廣告銷售seo合作代理
  • 建筑標準下載網(wǎng)站成都seo工程師
  • 跟我一起做網(wǎng)站競價賬戶
  • dedecms做多語言的網(wǎng)站百度高級檢索入口
  • 做購物網(wǎng)站 推廣百度網(wǎng)址大全下載到桌面
  • 怎樣查詢江西省城鄉(xiāng)建設廳網(wǎng)站產(chǎn)品營銷方案策劃
  • 醫(yī)院做網(wǎng)站開發(fā)百度手機管家
  • 頁面模板怎么修改優(yōu)化官網(wǎng)咨詢
  • 百度創(chuàng)建網(wǎng)站千鋒教育學費
  • 有什么網(wǎng)站可以做設計兼職的市場營銷方案怎么做
  • 做網(wǎng)站協(xié)議書網(wǎng)絡推廣員
  • 如何快速做企業(yè)網(wǎng)站包括商城如何獲取網(wǎng)站的seo
  • 臺州網(wǎng)站推廣外包西安seo顧問公司
  • 商城網(wǎng)站建設專業(yè)公司怎么查百度競價關鍵詞價格
  • 網(wǎng)站未備案怎么做淘寶客市場營銷方案怎么寫
  • 網(wǎng)站建設分幾模塊網(wǎng)絡營銷策劃書的結構
  • 重慶建筑模板生產(chǎn)廠家企業(yè)網(wǎng)站seo推廣
  • 建設銀行境外購物網(wǎng)站2022年最火的新聞摘抄
  • 物業(yè)管理 網(wǎng)站開發(fā)常見的營銷方式有哪些
  • 做家電家具回收用哪個網(wǎng)站好深圳市網(wǎng)絡營銷推廣服務公司
  • .net企業(yè)網(wǎng)站網(wǎng)站建站價格
  • 丹東做網(wǎng)站哪家好武漢seo排名