国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

請高手講講C語言函數(shù)strtok()和memcpy()

2019-11-17 05:27:08
字體:
供稿:網(wǎng)友

  請高手講講在sco unix 5.xx版本下, c語言strtok()和memcpy()函數(shù)的使用。
(本問題的用意:分割字符串。)
最好能有c語言編程的源程序。

函數(shù)名: strtok
功 能: 查找由在第二個串中指定的分界符分隔開的單詞
用 法: char *strtok(char *str1, char *str2);
#include <string.h>
#include <stdio.h>

int main(void)
{
char input[16] = "abc,d";
char *p;

/* strtok places a NULL terminator
in front of the token, if found */
p = strtok(input, ",");
if (p) ", p);

/* A second call to strtok using a NULL
as the first parameter returns a pointer
to the character following the token */
p = strtok(NULL, ",");
if (p) printf("%s
", p);
return 0;
}
函數(shù)名: memcpy
功 能: 從源source中拷貝n個字節(jié)到目標destin中
用 法: void *memcpy(void *destin, void *source, unsigned n);
程序例:

#include <stdio.h>
#include <string.h>
int main(void)
{
char src[] = "******************************";
char dest[] = "abcdefghijlkmnopqrstuvwxyz0123456709";
char *ptr;
printf("destination before memcpy: %s
", dest);
ptr = memcpy(dest, src, strlen(src));
if (ptr)
printf("destination after memcpy: %s
", dest);
else
printf("memcpy failed
");
return 0;
}

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 澳门| 广昌县| 静海县| 望都县| 咸丰县| 钦州市| 湾仔区| 旺苍县| 承德市| 马鞍山市| 毕节市| 蒙阴县| 德江县| 闸北区| 沙坪坝区| 兴义市| 长寿区| 宝应县| 庆元县| 阿鲁科尔沁旗| 都匀市| 攀枝花市| 甘洛县| 长葛市| 北碚区| 黄浦区| 宜兰市| 泰兴市| 柘荣县| 镇巴县| 广平县| 华亭县| 包头市| 当阳市| 开江县| 辉县市| 英超| 平江县| 内江市| 大渡口区| 龙陵县|