我在(ubuntu精确)linux系统上,我想从C中的字符串中删除前导字符(制表符).我认为以下代码正在处理我以前的安装(ubuntu oneric),但我发现它现在不起作用(请注意,这是一般UTF-8字符代码的简化版本):
#include dio.h>
#include
我做
gcc -o removetab removetab.c
执行removetab时我得到了
MY_LINE_ORIG= interface(quiet=true):
MY_LINE=interfae(quiet==true):
最佳答案
strcpy(my_char,my_char+1);
strcpy字符串不得重叠.
从C标准(强调我的):
(C99,7.21.2.3p2) “The strcpy function copies the string pointed to by s2 (including the terminating null character) into the array pointed to by s1. If copying takes place between objects that overlap,the behavior is undefined.“