if (strlen(shortest) > strlen(longest)) {
char *temp;
strcpy(longest, temp);
strcpy(shortest, longest);
strcpy(temp, shortest);
}
}
Run Code Online (Sandbox Code Playgroud)
strcpy(longest, temp) - >导致我的程序崩溃.这是一个详细的崩溃报告(我已经包含了正确的头文件,所以它不是.编译器警告我使用未初始化的临时变量...):
程序接收信号SIGSEGV,分段故障.
__strcpy_ssse3()at ../sysdeps/i386/i686/multiarch/strcpy-ssse3.S:85
85 ../sysdeps/i386/i686/multiarch/strcpy-ssse3.S:没有这样的文件或目录.
我很难理解从unsigned转换为Two的Complement时截断是如何工作的.有人可以解释一下吗?(我的textook使用将4位值截断为3位值的示例,并说-1变为-1,但-5变为3).