我是编程新手。请帮我解决这个问题。
当我执行这个程序时,程序会崩溃。谁能告诉我坠机的确切原因?
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
struct s
{
char *str;
};
std::vector<struct s> v;
int main()
{
struct s s1;
strcpy(s1.str,"hi");
v.push_back(s1);
strcpy(s1.str,"hello");
v.push_back(s1);
strcpy(s1.str,"How are you");
v.push_back(s1);
strcpy(s1.str,"AMAZING");
v.push_back(s1);
for (int i=0;i<(int)v.size();i++)
{
printf("%s\n",v[i].str);
}
return 0;
}
我正在用 devc++ 编译它。请帮忙。