Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi all,
I use code following code to create a Directory using toolkit
err = ProFileMdlnameParse(SelPath00, OutPutPath, MdlName, Ext, rev);
ProWstringToString(DwgName, MdlName);
mkdir(strcat("C:\\temp\\", DwgName))
When i run the application second time, the DwgName is getting appended.
(i.e first time DwgName is 1234, second time it becomes 12341234)
Kindly suggest.
Hi, probably due to the improper use of strcat.
Function strcat has first parameter the pointer to resulting array (this pointer is also returned), second param is string to append.
For the first time you append string to the end of array which begin at some address, second time append next string to this array and so on ... (string array will overlap, exception occurred).
Try to refill the result string (strcpy), at least, e.g.:
char dir [PRO_PATH_SIZE];
strcpy(dir, "C:\\temp\\");
strcat(dir, DwgName);
Btw: You should not use strcat, try something like ProTKSnprintf
PZ
At least strcat_s(dir, PRO_PATH_SIZE, DwgName); so you get a crash at "out of allocated memory" and not write over other variables/allocated space inside your memory.
Br,
Eike
You should init a char string
DwgName[0] = '\0';
before using.