Scripting language

This is a discussion on Scripting language within the C++ Programming forums, part of the General Programming Boards category; the tgz: http://www.geocities.com/martian0_1/download/EasyC.tgz the zip: http://www.geocities.com/martian0_1/download/EasyC.zip I get an illegal operation on startup. What is wrong with it? Thank you....

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Scripting language

    the tgz:
    http://www.geocities.com/martian0_1/download/EasyC.tgz

    the zip:
    http://www.geocities.com/martian0_1/download/EasyC.zip

    I get an illegal operation on startup. What is wrong with it? Thank you.
    This war, like the next war, is a war to end war.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    161
    Code:
    char * out;
    char * instring;
    char * foutstring;
    char * comm;
    You can't store data with these pointers until you point them to some valid allocated memory.

    Why not use std::string instead?

  3. #3
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    I put char intring[100] and things like that as i got syntac error before ';'. However it still doesn't work. What am i doing wrong??
    Attached Files Attached Files
    This war, like the next war, is a war to end war.

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    161
    Try this code. I changed your character arrays to use STL strings and also changed the "end" command to "kill" so that the input file would work correctly.

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    #include <cstring>
    #include <fstream>
    #include <conio.h>
    #include <windows.h>
    
    const char * file = "main.ec";
    const char * outfile = "Out File.txt";
    
    ofstream fout(outfile);
    
    string out;
    string instring;
    string foutstring;
    string comm;
    
    void output()
    {
     cout << out;
    }
    
    void newline()
    {
     cout << endl;
    }
    
    void input()
    {
     getline(cin, instring);
    }
    
    void fileout()
    {
     fout.open(outfile);
     fout << foutstring;
     fout.close();
    }
    
    void filenewline()
    {
     fout.open(outfile);
     fout << endl;
     fout.close();
    }
    
    void pause()
    {
     getche();
    }
    
    void wait()
    {
     Sleep(1000);
    }
    
    void kill()
    {
     exit(0);
    }
    
    int main()
    {
     ifstream fin;
     fin.open(file);
     while (1)
     {
      getline(fin, comm);
    
      if(comm == "out")
      {
       getline(fin, out);
       output();
      }
      else if (comm == "newline")
      {
       newline();
      }
      else if (comm == "input")
      {
       input();
      }
      else if (comm == "fileout")
      {
       getline(fin, foutstring);
       fileout();
      }
      else if (comm == "filenewline")
      {
       filenewline();
      }
      else if (comm == "pause")
      {
       pause();
      }
      else if (comm == "sleep")
      {
       wait();
      }
      else if (comm == "kill")
      {
       fin.close();
       kill();
      } 
     }
    
     return 0;
    }

  5. #5
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Hey, thanks, it works...

    No only if i can learn OGL, i can make that scripted.... lol.

    I owe you one, pal. Ill give you a PM if any more problems come up. And thanks again!
    This war, like the next war, is a war to end war.

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    161

    Thumbs up

    Glad to have helped.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reviving my old scripting language.
    By suzakugaiden in forum Game Programming
    Replies: 4
    Last Post: 06-15-2006, 04:02 PM
  2. What's the Difference Between a Programming Language and a Scripting Language?
    By Krak in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 07-15-2005, 05:46 PM
  3. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 02:40 PM
  4. C Language And A Scripting Language
    By DarkSpy in forum C Programming
    Replies: 9
    Last Post: 06-26-2003, 09:05 AM
  5. How would I go about making a scripting language...
    By gcn_zelda in forum C++ Programming
    Replies: 1
    Last Post: 06-19-2003, 12:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21