I am reading a char array newpath that contains C:\\Program Files\\test software\\app . How to substitute the space to underscore character?
char newPath2[MAX_PATH];
int newCount2 = 0;
for(int i=0; i < strlen(newPath); i++)
{
if(newPath[i] == ' ')
{
newPath2[i] = '_';
}
newPath2[newCount2]=0;
}
newCount2is always 0, I think you need to increment this counter too. If not Im not sure what you are doing with this statementnewPath2[newCount2]=0;I think you want this: