Reputation: 119
In my code I'm opening an output stream and appending the data to the end of the file .. if there is no such file the stream should create one but the problem that it does not.
here is the code snippet:
char output_file[100];
strcpy(output_file, predicate.c_str());
ofstream output_file_ptr1;
output_file_ptr1.open(output_file,ios::out | ios::app | ios::binary );
if(output_file_ptr1.is_open()){
output_file_ptr1 << subject <<" " << object <<"\n";
output_file_ptr1.close();
}
else{
printf("Error opening out file \n");
return -1;
}
subject, object and predicate are variable strings that I created earlier.
Any idea it does not create the file? + it is very important for me that the data is appended to the end of the file.
Update: predicate is the exact file name that I need , but it is not a usual naming i.e
is an example
Upvotes: 0
Views: 667
Reputation: 16419
A value such as <w3.org/1999/02/22-rdf-syntax-ns#type>
is not a valid file name in most environments. Unix-style operating systems (e.g. Linux) do not support "/" inside the file name (unless the directory structure matches).
Upvotes: 1