I am trying to create processes for my project. I will pas arguments to child process from parent and the argument will change in time, so i wanted to make a try first with passing 1 to the child. The string format should be like this "childname.exe c" where c represents random character (in this case it is 1 for just trial).
I created a childname array and and all i wanted was concatenate the new string with childname string and copy it to another string array(lpCommandLine variable). When i debugged the code below i saw that child_name[0] (when i is equal to 0) returns only 'C' although i expected it to return "ChildProj1.exe". Is there a point that i missed or how to do it in c?
here there is a image of what i getin debugger: here stored values of in variables
#define NO_OF_PROCESS 3
char *child_names[]= {"ChildProj1.exe", "ChildProj2.exe", "ChildProj3.exe" };
char* lpCommandLine[NO_OF_PROCESS];
int i;
for (i = 0; i < NO_OF_PROCESS; i++)
lpCommandLine[i] = (char *)malloc(sizeof(char) * 16);
for (i = 0; i < NO_OF_PROCESS; i++)
{
strcat_s(child_names[i], strlen(child_names[i]), " 1");
strcpy_s(lpCommandLine[i], strlen(lpCommandLine[i]), child_names[i]);
}