M
mattsniderppl
Hi, i'm relatively new to C++ from java and am having a difficult time
with pointers. I'm sure there is something simple that I am doing
wrong, but I can't seem to write this in a way that doesn't give me the
error "Unable to write to memmory." This is a static function that
receives a string that is the name of a file and an ifstream pointer.
It then concatenates the path string using the string.h function
strcat(char *, const char *) and then opens the infile. However, both
the strcat call and the open call returns the error message. Any ideas
what i'm doing wrong here? Thanks.
void STATICFUNCTIONS::OPENFILE(char * name, ifstream * infile) {
char * path = "C:\\Dev-Cpp\\projects\\exe\\";
strcat(path, name);
infile->open(path, ios::in);
if (!infile->is_open()) throw strcat("Error Opening ", path);
try {
} catch (char * str) {
cout<<str<<endl<<"Program will exit now"<<endl;
system("PAUSE");
exit(1);
}
}
with pointers. I'm sure there is something simple that I am doing
wrong, but I can't seem to write this in a way that doesn't give me the
error "Unable to write to memmory." This is a static function that
receives a string that is the name of a file and an ifstream pointer.
It then concatenates the path string using the string.h function
strcat(char *, const char *) and then opens the infile. However, both
the strcat call and the open call returns the error message. Any ideas
what i'm doing wrong here? Thanks.
void STATICFUNCTIONS::OPENFILE(char * name, ifstream * infile) {
char * path = "C:\\Dev-Cpp\\projects\\exe\\";
strcat(path, name);
infile->open(path, ios::in);
if (!infile->is_open()) throw strcat("Error Opening ", path);
try {
} catch (char * str) {
cout<<str<<endl<<"Program will exit now"<<endl;
system("PAUSE");
exit(1);
}
}