sstream

¿Has encontrado un error? ¿Tienes la solución? Deja tu correción ;-)

Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress las eliminó al verlas como etiquetas HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios. Y lo mas importante: Todos los ejemplos fueron realizados por estudiante con únicamente conocimiento básico del lenguaje, no de programación.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Program TestStream;
 
uses classes;
 
Var Stream : TStringStream;    S,T : AnsiString;
 
begin
  S:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  T:=S;  Writeln ('Creating stream.');
  Stream:=TStringStream.Create(S);
  Writeln ('Initial Size : ',Stream.Size);
  Writeln ('Initial Position : ',Stream.Position);
  Writeln ('Setting new size to 100');  Stream.Size:=100;
  Writeln ('New Size : ',Stream.Size);
  Writeln ('new Position : ',Stream.Position);
  Stream.WriteByte  (1);
  Stream.WriteWord  (2);  Stream.WriteDWord (3);
  Stream.WriteString (S);
  Writeln ('Size after write : ',Stream.Size);
  Writeln ('Position after write : ',Stream.Position);
  Writeln ('Truncating size');  Stream.Size:=Stream.Position;
  Writeln ('Stream Size is : ',Stream.Size);
  Writeln ('Stream Position : ',Stream.Position);
  Writeln ('Seek to position 0 : ', Stream.Seek(0,soFromBeginning));
  Writeln ('new Position : ',Stream.Position);  If Stream.ReadByte<>1 then  Writeln ('First byte not 1');
  If Stream.ReadWord<>2 then  Writeln ('First word not 2');
  If Stream.ReadDWord<>3 then Writeln ('First Word not 3');
  T:=Stream.ReadString(Length(S));
  If Length(T)<>Length(S) then    Writeln ('Couldn''t read string.');
  Stream.WriteByte  (1);
  Stream.WriteWord  (2);
  Stream.WriteDWord (3);
  Stream.WriteBuffer (S[1],Length(S));  Writeln ('Stream Size is : ',Stream.Size);
  Stream.Free;
end.

3 comentarios en "sstream"

andree

me an dejado un ejercicio para hacerlo con el metodo de stream con la clave sistema y no se como empezar :(

Punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:

  • Si es lenguaje C <code lang="c">Código en C</code>
  • Si es lenguaje Pascal <code lang="pascal">Aquí dentro el código de Pascal</code>.

De esta manera el código coloreas el código.

Deja un comentario

Suscribirse a los comentarios.