c - strcpy() 不能正常工作

c - strcpy() 不能正常工作

我目前正在编写一个程序,其中我陷入了 strcpy() 函数的另一种行为。这是它的简短演示......

我经历了以下问题:从 C 字符串中删除第一个和最后一个字符

//This program checks whether strcpy() is needed or not after doing the modification in the string

#include

#include

int main()

{

char mystr[] = "Nmy stringP";

char *p = mystr ;

p++;

p[strlen(p)-1] = '\0';

strcpy(mystr,p);

printf("p : %s mystr: %s\n",p,mystr);

}

输出 :-

p : y strnng mystr: my strnng

如果我不使用 strcpy() 函数,那么我得到

p : my string mystr : Nmy string

为什么会这样??

相关推荐

各个快递多少钱一公斤(2022年快递收费标准价格表大全)
1998年世界杯1/8决赛 阿根廷6比5英格兰
365bet足球网投

1998年世界杯1/8决赛 阿根廷6比5英格兰

📅 07-09 👁️ 4372
皇室战争:官方称他核心卡,玩家称他“万金油”,矿工凭什么?