【发布时间】:2017-05-20 17:47:57
【问题描述】:
#include<stdio.h>
int main(){
char a[20],*p;
p=a;
printf("Enter the String");
scanf("%s",p);
printf("\n\n%s\n",p);
printf("Copying the String\n");
char b[20],*pp;
pp=b;
while((*pp++=*p++));
printf("\n%s\n",pp);
}
此代码不复制字符串。但是,如果我将 b[20] 更改为 b[10],它会复制字符串的最后 9 个字符。顺便说一句,当我设置 b[10] 时,如果输入包含空格,那么它不会复制字符串。
编译器设置:
配置为:--prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM 版本 8.1.0 (clang-802.0.42)
目标:x86_64-apple-darwin16.5.0
线程型号:posix
安装目录:/Library/Developer/CommandLineTools/usr/bin
【问题讨论】:
-
为什么要用c++标签?