Are you sure you need to double-slash the path? The purpose of double-slashing is to tell the compiler whether you're entering a backslash code (which is stored as a single character) or a literal backslash character. But once the string is stored, a backslash character is a backslash character.
For example,
strcpy(myPath, "c:\\application Data\\0001");
// myPath now contains c:\application Data\0001
// Now both \'s are literal characters:
// \a is two characters, not the single character alert (bell)
// \0 is two characters, not the single character NULL
But, if your DBConnect Connection String requires double-backslashes (and I don't know if it does), the general idea is to copy your existing string to a new string, one character at a time, and if the current character in the existing string is a \, add another one to your new string.
Try something like this.
// remove the spaces after the < (I added them to fool the forum's HTML error detection)
#include < ansi_c.h>
#include < utility.h>
main()
{
char singleSlashPath[MAX_PATHNAME_LEN];
char doubleSlashPath[MAX_PATHNAME_LEN];
int i, j=0;
strcpy (singleSlashPath, "c:\\my documents\\my project");
for (i=0; i < strlen(singleSlashPath); i++)
{
// copy a character from singleSlashPath to doubleSlashPath
// then increment the doubleSlashPath index
doubleSlashPath[j++] = singleSlashPath[i];
if (singleSlashPath[i] == '\\')
// add another \ then increment the doubleSlashPath index
doubleSlashPath[j++] = '\\';
}
doubleSlashPath[j] = '\0'; // terminate doubleSlashPath
}