I am getting segfault error when I tried the following. I am getting some arguments dynamically to the program. I have to concatenate all of them into a single string and operate on it. I have written the following code for concatenating all the arguments into one string.
int main(int argc, char** argv){
string input;
for(int i=1;i<=argc;i++)
{
input+= argv[i]+string(" ");
}
//code for operating on the string. code not yet written
return 0;
}
I am getting segfault when the arguments are more. If the arguments are 10-20, then there is not segfault. But when the arguments are 100, I am getting segfault. I tried using char[] in c++. but that also giving the same error. How to handle this?