M
Morris.C
I've had to do some editing of a C++ program that was origianlly created
by a departed colleague of mine.
What I need to do is change a certain part of a string. The string
contains a file name. The file name is taken from an environmental
variable.
This is what I did: (I'm not including any variable declarations.)
filename = getenv("FILENAME");
len = strlen(filename);
len1 = len - 4;
strncpy(filenamenew,filename,len1);
strcat(pch,"backup1");
Eg. If filename/FILENAME is a1b2c3d4.text, the variable 'pch' ends up
being a1b2c3d4.backup1.
The length of filename can change.
I know that I always want to delete the last four characters.
Now the problem: (He finally gets to the point!!)
'pch' ends up having gobbledoogook (ie.crap) between 'a1b2c3d4.' and
'backup1'.
Eg. a1b2c3d4.}@*backup1
Why?
Where is it coming from?
Is there a single function that will do this?
(I couldn't find one at http://www.cplusplus.com/ref/ !!)
Thanks,
Morris.C
Melbourne, Australia
by a departed colleague of mine.
What I need to do is change a certain part of a string. The string
contains a file name. The file name is taken from an environmental
variable.
This is what I did: (I'm not including any variable declarations.)
filename = getenv("FILENAME");
len = strlen(filename);
len1 = len - 4;
strncpy(filenamenew,filename,len1);
strcat(pch,"backup1");
Eg. If filename/FILENAME is a1b2c3d4.text, the variable 'pch' ends up
being a1b2c3d4.backup1.
The length of filename can change.
I know that I always want to delete the last four characters.
Now the problem: (He finally gets to the point!!)
'pch' ends up having gobbledoogook (ie.crap) between 'a1b2c3d4.' and
'backup1'.
Eg. a1b2c3d4.}@*backup1
Why?
Where is it coming from?
Is there a single function that will do this?
(I couldn't find one at http://www.cplusplus.com/ref/ !!)
Thanks,
Morris.C
Melbourne, Australia