I need to convert a pascal code to C++

I need to do a Homework and its been buzzing my skull cracked open.

I have to write a program on c++ or modify this pascal code.

to write,erase or find a record in a archive.

the record has to have the camp:

empid (negative if the record is erased)
apellido
nombre
edad
salario

I dont know where to start. or what to add im a noob.

Pascal code

program empleados;
type persona=record
nombre,apellido:string;
edad,empid,instruccion:integer;
salario:real;
end;

var
empleado: ^persona;
plantilla: file of persona;
estapersona:integer;
siono:string;

begin
new(empleado);
estapersona:=0;
assign(plantilla,'empleados.dat');
{Anadir record}
reset(plantilla);
while not eof(plantilla) do
begin
read(plantilla,empleado^);
if abs( empleado^.empid) >estapersona then estapersona:=abs(empleado^.empid);
end;
{repeat}
repeat
write('Nombre del empleado: ');
readln(empleado^.nombre);
write('Apellido: ');
readln(empleado^.apellido);
write('Edad: ');
readln(empleado^.edad);
write('Salario: ');
readln(empleado^.salario);
writeln('Verifique:');
writeln('Nombre:', empleado^.nombre);
writeln('Apellido:', empleado^.apellido);
writeln('Edad:', empleado^.edad);
writeln('Salario:', empleado^.salario);
write('Correcto Si/No:');
readln(siono);
until siono='Si';
inc(estapersona);
empleado^.empid:=estapersona;
write(plantilla,empleado^);
{write('Otro? Si/No');
readln(siono);
until siono='No';}
close(plantilla);
{/Anadir record}
reset(plantilla);
while not eof(plantilla) do
begin
read(plantilla,empleado^);
writeln(empleado^.nombre,' ',empleado^.apellido);
end;
close(plantilla);
end.
closed account (S6k9GNh0)
I'll look into it. PASCAL was my very first language but that was years ago.
In the meantime, the application seems kinda simple. Write = printf in C. Writeln is write on a new line. readln is cin. The rest are loops etc. I will help you out but I'm not going to just give you my code.

If you know what Assign, Reset, and New does, you should be able to figure out what to do in C++.
Last edited on
Awsome now im more relaxed that i got someones attention as i go on. ill post what i done so far.

but no you see all my classes have been on C++, and this new teacher just wanted to be special and gave us pascal but i dont understand anything about pascal i know a bit more of C++.
Last edited on
If your course is in Pascal, you might as well learn it. It isn't very much of a jump from something like C++.

The Wikipedia article is a pretty good start. (You are using a Borland variant of Pascal.)
http://en.wikipedia.org/wiki/Pascal_(programming_language)
See also the links at the bottom of the page for some good tutorials and other resources.

Hope this helps.
Topic archived. No new replies allowed.