c語言 字串操作

2021-08-04 02:58:15 字數 759 閱讀 3403

#include #include #include /*

將to的路由器ip更換為from的sip server ip

*/int main()

fromstart = indexof(from,"@");

fromip= (char *)malloc(fromlen-fromstart);

substring(fromip,from,fromstart,fromlen);

printf("from ip is %s\n",fromip);

//2. 取出to的sip account

tostart = indexof(to,"sip:");

toend = indexof(to,"@");

if(toend > tostart)

free(fromip);

}getch();

return 0;

}void substring(char *dest,char *src,int start,int end)

dest[i-start]='\0';

return;

}int indexof(char *str1,char *str2)

}return i;

}

因為第一次使用c語言,所以將一些基本注意事項記錄一下:

1.所有宣告必須緊跟在 { 後面

2.使用malloc動態分析記憶體,使用free釋放

C語言字串操作函式

引用自 1.字串反轉 strrev 2.字串複製 strcpy 3.字串轉化為整數 atoi 4.字串求長 strlen 5.字串連線 strcat 6.字串比較 strcmp 7.計算字串中的母音字元個數 8.判斷乙個字串是否是回文 1.寫乙個函式實現字串反轉 版本1 while版 void st...

C語言字串操作函式

c語言字串操作函式 1.字串反轉 strrev 2.字串複製 strcpy 3.字串轉化為整數 atoi 4.字串求長 strlen 5.字串連線 strcat 6.字串比較 strcmp 7.計算字串中的母音字元個數 8.判斷乙個字串是否是回文 1.寫乙個函式實現字串反轉 版本1 while版 v...

C語言字串操作函式

1.函式名 stpcpy 功 能 拷貝乙個字串到另乙個 用 法 char stpcpy char destin,char source 程式例 include include int main void 2.函式名 strcat 功 能 字串拼接函式 用 法 char strcat char des...