so here's the thing I've been working on a code for 5 hours now and logic looks good the program seems to do it's job, the only thing that keeps bugging me is dynamic memory allocation of strings. The question does not specify the initial number of strings user has to enter. Here's what I've been trying to do to dynamically take the strings :
int t;
cin>>t //number of strings user wishes enter
char *s1[1000009]; //1000009 is the maximum number of digits each string can have
for(i=0;i<t;i++)
{
s1[i]=(char *)malloc(1000009)
cin>>s1[i];
}
not sure if it is the right way or not. A way through which i could store a 2D character array would also do if not dynamic strings.
Thanking you, gaurav
std::vectorandstd::string.mallocfor manual dynamic allocation. Usenewinstead. Don't use manual dynamic allocation at all. Usestd::stringinstead.