首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

函数运行总是出现“段异常”

2013-08-09 
函数运行总是出现“段错误”#includestring.h#includestdio.h#includestdlib.hintmain(){char *chcha

函数运行总是出现“段错误”
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
int
main()
{
    char *ch;
    char s[120]= "ok/hello:hello,let you Go ahead";
    strcpy(ch,s);
    printf("%s\n",ch);
    char *pt;
    memset(pt,0,sizeof(pt));
    pt = strsep(&ch,":");
    printf("%s\n",pt);
    return 0;
}
//运行结果想得到ok/hello

好吧! 我看错了!没清楚下面那个函数是分割字符串的函数!

热点排行