Ok i just started C++ about 2 days ago and I have somthing not working and somthing I need to ask, hopfully somone can help me.

Im making a dll to use with a gamemaking software called gamemaker that support using dll's.

oh ya, im using Dev-C++

First, This is not returning 'yes' or 'no', why:

export char* file_write(const char* file_name, const char* file_value){
      const char* done = "no";
           ofstream EmplRecords(file_name);
    EmplRecords << file_value;
    if (EmplRecords.fail()){
                           done = "no";
                           }else{
                                 done = "yes";
                                 }
    EmplRecords.close();
return(char*)done;
 
       }

And second, how do you delete a file that you've writed to? This is my current code:

export char dos_execute(char temp_name, char command){
          ofstream EmplRecords(temp_name+".bat");
    EmplRecords << command;
               EmplRecords.close();
       system(temp_name+".bat");
       }

Thnx in advance.

~Mini_The_Great

Regarding your first question... what is it returning if it isn't returning Yes or No?

Using strings in this way isn't safe. If returned value needed for user output, use class string. If not, the better way to use bool or some kind of numerical constant to return status from function. bool would be more simple and safe.
so:

bool file_write(/*...*/){
 bool status=true;
 if(EmplRecord.fail())status=false;
 EmplRecord.close();
 return status;
}

Perhaps a garbage collector could delete the data pointed by const char* done. It would work in non-export function.

to delete a file, you can use unlink function:
unlink(filename);

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.