Introdu of variables in the file



  • We need to record variable n in one line, and variable m in another line. The code, of course, has written, simple, and I don't see any mistakes. But the compiler is in line:

    append(gr_vhod);
    

    A report of the wrong guy. What needs to change?

    program z_5;
    

    uses crt;

    type gr = file of integer;

    var n : integer;
    m : integer;
    gr_vhod : gr;

    BEGIN
    assign(gr_vhod,'vhod.txt');
    rewrite(gr_vhod);

    writeln('Vvedite N: ');
    readln(n);

    write(gr_vhod,n);

    close(gr_vhod);

    writeln('Vvedite M: ');
    readln(m);

    append(gr_vhod);
    write(gr_vhod,m);

    END.



  • Let's take care of it.

    BEGIN
       assign(gr_vhod,'vhod.txt');
       rewrite(gr_vhod);
    

    writeln('Vvedite N: ');
    readln(n);

    write(gr_vhod,n);

    close(gr_vhod);

    writeln('Vvedite M: ');
    readln(m);

    append(gr_vhod); // append должна идти после чего? правильно после Assign() которого нет после close(); правильно?
    write(gr_vhod,m);
    // закрываем файл
    END.

    We'll take the answer and we'll code it carefully next time.

    The ps in the file will only be the last variable!

    You're not the only one who's got the logic to turn on!

    First file doesn't have to be.

    type gr = file of integer;

    Just...

       type gr = file;

    type gr = file of string;

    And then one time, open it twice and close it.
    No one will write for you. There's nothing more to do with your task.
    The logic, imagination, and the desire to study the ropes should be included.

    PS by the way

    program blah-blah;

    You can't write when you learn correctly and fast writing on the pascal, and every line in the code will be written in "va" that line is needed for the name of the program, it's not used anywhere, it's easier to write comments on what the program is, but it's probably after it's written.

    It's a little shorter.

    uses crt;
    type gr=file of string;
    var n,i : integer;
    gr_vhod : gr;
    BEGIN
    assign(gr_vhod,'vhod.dat');
    rewrite(gr_vhod);
    for i:=1 to 2 do
    Begin
    write('Vvedite '+i+' chislo: '); // синтаксис не помню
    readln(n);
    writeln(gr_vhod,n);
    End;
    close(gr_vhod);
    ReadLn;
    END.

    The way I loved the pasta, so it's always possible to cut the code after it's been written, especially the functions and procedures that you put in your own model, so the program is actually falling in number.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2