#include <stdio.h>
#include <stdlib.h>
int main(void)
{
//char s[6] = {'h','e','l','l','o','\0'};
char *s = "hello";
int i=0,m;
char temp;
int n = strlen(s);
//s[n] = '\0';
while (i<(n/2))
{
temp = *(s+i); //uses the null character as the temporary storage.
*(s+i) = *(s+n-i-1);
*(s+n-i-1) = temp;
i++;
}
printf("rev string = %s\n",s);
system("PAUSE");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在编译时,错误是分段错误(访问冲突).请告诉我们两个定义有什么区别:
char s[6] = {'h','e','l','l','o','\0'};
char *s = "hello";
Run Code Online (Sandbox Code Playgroud) void main()
{
char *p = "hello";
}
Run Code Online (Sandbox Code Playgroud)
P的存储类型和内存中的点(堆栈/数据段)是什么?字符串"helllo"存储在哪里?
请阐明 shell 命令之间的区别。script.sh 与 ./script.sh 其中 script.sh 是一个 shell 脚本。
谢谢
如何调试在Linux上启动二进制文件导致的分段错误?没有源代码可用于二进制文件.
如何知道导致seg故障的二进制文件的系统调用.有没有可能有帮助的调试实用程序?