Question

I have made a scripting language and I was writing a program which would 1: Ask for your path to read the script and 2: Compile the code into a custom Hexadecimal which would be read by another program to do the hard work for me. My problem is I cannot create a new file and write the custom hexadecimal code onto that file.

Here is an example of my code:

#include <iostream>
#include <string>
#include <Windows.h>
#include <wincon.h>
#include <fstream>;
using namespace std;

int main(){
string path;
string title;
cout << "Enter your path to compile your *.egSCRIPT file: ";
cin >> path;
cout << "Enter the title for the new file";
cin >> title;

ofstream myfile(path+"\\"+title+".myScriptLanguage");
myfile.open(path);
myfile << "IT WORKS!!!";
myfile.close();
return 0;
}

I want it to make a new .whatevertheheckyouwanttocallit file and write onto the file IT WORKS!!! just as a sample. I will eventually write onto it a custom hexadecimal system of code to be read by my interpreter. Thanks in advance.

Was it helpful?

Solution

ofstream myfile;
myfile.open(path+"\\"+title+".myScriptLanguage");
myfile << "IT WORKS!!!";
myfile.close();

Try the above;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top