|
-
May 20th, 2005, 06:58 AM
#1
C++ program compilation error
I have written a class to append a location to 'PATH' environment variable. When i try to compile the code, i'm getting error as
"error C2040: 'clientDllPath' : 'class kkAddToPath' differs in levels of indirection from 'char *'". Is there any error in this code?
class kkAddToPath {
public:
kkAddToPath() {
}
kkAddToPath(char *Path) {
char *curPath = getenv("PATH");
m_oldPath = new char[strlen(curPath) + 10];
strcpy(m_oldPath, curPath);
char *newPath = new char[strlen(curPath) + strlen(Path) + 20];
sprintf(newPath, "%s%s%s%s", "PATH=", Path, ";", m_oldPath);
putenv(newPath);
delete [] newPath;
}
~kkAddToPath() {
char *oldPath = new char[strlen(m_oldPath) + 10];
sprintf(oldPath, "%s%s", "PATH=", m_oldPath);
putenv(oldPath);
delete [] oldPath;
delete [] m_oldPath;
}
private:
char *m_oldPath;
};
void main(int argc, char* argv[])
{
char *path = argv[1];
kkAddToPath(path);
}
Thanks
BM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|