Hi,
I have searched the forum and google and wondered if anyone can answer the following:
This is my code for reading a pchar null terminated string from a file which seems to work ok, in this example I know the string is 16 bytes long.
My question is if I don't know how long the string is can I use pchar to read a string from a file until it reads the null, if yes how?
I tried "CurrentFile.ReadBuffer(MyName,255);" (as 255 is max size of name) but the program crashes prob because the total filesize was only 50 bytes in size.
Hope I have made myself clear ?
I have searched the forum and google and wondered if anyone can answer the following:
This is my code for reading a pchar null terminated string from a file which seems to work ok, in this example I know the string is 16 bytes long.
Code:
var
CurrentFile : TFilestream;
MyName : PChar;
CurrentFile.ReadBuffer(MyName,16);
Add(' Name: '+PChar(@MyName));
My question is if I don't know how long the string is can I use pchar to read a string from a file until it reads the null, if yes how?
I tried "CurrentFile.ReadBuffer(MyName,255);" (as 255 is max size of name) but the program crashes prob because the total filesize was only 50 bytes in size.
Hope I have made myself clear ?