I m newbie to programming. Please help me with this question.
when i execute this program, program will crash. can anybody tell me the exact reason for the crash?
#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;
}
i am compiling it in devc++. pls help.