char*跟char[]的strcpy出错

char*和char[]的strcpy出错
#include<iostream>
int main()
{
char *a = NULL;//"test";
char b[5]= "test";
strcpy(b,a);
std::cout<<b;
system("pause");
}

为什么这样写总是copy不了呢?vs老是中断在strcat.asm里,什么原因呢?是不是strcpy还调用了strcat啊?
还是有其他原因呢,谁知道原理告诉我一下,还有,具体需要怎么改,谢谢!
strcpy char* char[]

------解决方案--------------------
strcpy不接受NULL指针,会报错的。
------解决方案--------------------

char *strcpy(char *dest, const char *src);
//第二个参数是常指针的
he  strcpy()  function copies the string pointed to by src, including the terminating null byte ('\0'), to the buffer pointed to by dest.

------解决方案--------------------
引用:
a和b反了。。。而且拷贝源必须是C风格字符串,望留意!

错了 反过来也不对,不能往NULL里面拷东西。。。
------解决方案--------------------
引用:
Quote: 引用:


char *a = "k"; //静态区,只可读,不能修改
char b[5] = "xxx"; //一般栈区,可读可写
//注意越界问题
这怎么能是静态的呢,修改完全没问题啊

如果你往a里拷贝就有问题了
------解决方案--------------------
引用:
Quote: 引用:


char *a = "k"; //这个是常量字符串,存放在静态区,只可读,不可改!!!!

//有时间看看内存管理吧!
我这修改a完全没问题
#include<iostream>
int main()
{
char *a = "l";//"test";
char *b= "test";
a = "ss";
//strcpy(a,b);
std::cout<<a;
system("pause");
}

你修改a是修改的a的指向,不能修改的是用下表操作时
------解决方案--------------------