Hi,

I don't know why the member variable of my class is getting a wrong value. I just want to copy a char array to member variable that is also a char array.

What is wrong?

Thanks!

// constructor
filewatcher::filewatcher(char filename[])
{
    // filename to watch
    strcpy(this->_filename, filename);
}

Is that
char *_filename;
or
char _filename[1000];

Or why are you messing with char arrays when there is a perfectly usable std::string which would have seen you finished hours ago.

Is char _filename[1000]; anyway I'll try it with string!

Thanks!

Is that
char *_filename;
or
char _filename[1000];

Or why are you messing with char arrays when there is a perfectly usable std::string which would have seen you finished hours ago.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.