Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How to make my own porgram language (http://www.go4expert.com/forums/porgram-language-t6925/)

aVague 19Oct2007 19:01

How to make my own porgram language
The problem is , how to write interface to a program

For example , I want to work with a set of points (they have coordinats) , the thing is how concrete can I realize commands .
I compile program , then I start it , write adress of file with points and then write add (4;6) , and this comand should add point with coordinats (4;6) to the file wich adress I wrote

DaWei 19Oct2007 19:27

Re: How to make my own porgram language
Your question is not clear. I don't think you want to write your own programming language. I think you probably want to use C/C++ to accept number pairs (coordinates) from the user and write them to a file.

You'll need to be clear which of those you want, however.

aVague 19Oct2007 23:21

Re: How to make my own porgram language
second, as you guessed

DaWei 19Oct2007 23:36

Re: How to make my own porgram language
Here's the deal, then.

Open a file for output.

Set up a while loop. Inside the loop, ask the user to enter two numbers. Validate the input and, if correct, write them to the file. Exit the loop on some input condition, such as an empty line.

Close the file.

The particular functions you use for file I/O and for user input will depend on whether or not you are using C or C++. You don't say, and you don't give any indication of your level of expertise.

I would strongly recommend you read this .

aVague 20Oct2007 09:36

Re: How to make my own porgram language
Oh, sorry , I m using C on unix platform , and I am working in Vim.Your advice is clear to me , I ll try to do so , but I want to use commands too. As I suppose , I need to make some functions for that like if to print word "add" and press enter , one of the functions ll be used. How to do that?

aVague 21Oct2007 13:46

Re: How to make my own porgram language
I ll try to realize it and show it then

aVague 1Nov2007 14:19

Re: How to make my own porgram language
so here it is


FILE *fp;

 int func_1(int n,double w[],double v[])
  {  int i;

    if(fp==NULL) write("can't open");
    return 13;
    { putchar(w[i]); putchar(v[i]);}

return 7;

void main()

  int N,i;
  char z;
  double *oX,*oY;

 printf("what would you like to do now?\n");

switch (z)
{case 'add': printf("\n enter: 1)number of points you wish to add 2)coordinates of points ");
oY= (double*)malloc(N*sizeof(double));

 case 'q' :break;}
// getchar();
// getchar();

there are some mistakes(in a logic of a program) , I think , help me to find them

All times are GMT +5.5. The time now is 20:00.