How does writeln knows its the end of a string?
I have the following code:
String = packed array[1..256] of char;
var
Test: String;
begin
Test:='Hello world';
writeln (Test);
Test[8] := Test[12];
writeln (Test);
end.
The output is:
Hello world
Hello w rld
How does writeln knows where to stop printing the
string?
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
Hi,
The coding conventions for gcc 3.4 and up say to no longer use k&r
style definitions.
Is gpc going to follow suit? I.e. Will patches to remove PARAMS and
switch away from
k&r style definitions be accepted?
--
Thanks,
Jim
http://phython.blogspot.com
Hi,
This patch wraps most long lines to under 79 characters. It has
been built and
tested on ia64-linux along with the other previous two patches.
--
Thanks,
Jim
http://phython.blogspot.com
I have the following code:
function nString2nList (Str: String; var
Num:Number):boolean;
var
CurrentChar: integer;
begin
CurrentChar:=0;
while (Str[CurrentChar]<>'a') do
begin
writeln (Str[CurrentChar]);
CurrentChar:= CurrentChar+1;
end;
nString2nList:=true;
end;
begin
nString2nList ('-0123a', Num1);
end.
I get the following error on the one before last line:
function call as a statement - value is ignored
__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250
The trouble is we had only one hour lecture on pascal
and we wont have any more on this issue.
I havnt found any decent refernce on GPC pascal.
Is there any good reference on the web for GPC pascal?
I hope that people wont get tired on answering me on
those compilation errors, eventhough they are simple
because these errors really get me stuck.
Of course you dont have to answer if you dont want to.
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
I have defined a String = ^ char type which fixed the
error in line 44. However I still have an error in
line 17.
Additional question, how do I get a data from ^ char
pointer?
If I have:
a: ^ char;
In c I would do the follwoing, either:
*a = 'a';
or
a[0] = 'a';
How do I do the equvalent in GPC?
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
I omitted the additional type and the first
compilation error has been removed.
Now I have two additional compilation errors.
My code is:
program Ex1 (input, output);
type NumNode = record
Value: integer;
pNext: ^ NumNode;
end;
nNumber = record
DigitsAmount: integer;
DigitValue:^ NumNode;
MSD: integer;
DigitBase: integer;
end;
function nNumberIsEmpty (Num: nNumber): boolean;
begin
nNumberIsEmpty := (Num.DigitValue=0);
end;
function nNumberPop (var Number: nNumber): integer;
var
pNextValue:^ NumNode;
begin
if (nNumberIsEmpty(Number)) then
nNumberPop:=0;
else
begin
Number.DigitsAmount:=Number.DigitsAmount-1;
pNextValue :=
Number.DigitValue^.pNext;
dispose (Number.DigitValue);
Number.DigitValue:=pNextValue;
if (Number.DigitsAmount=0) then
begin
Number.MSD:=0;
nNumberPop:=0;
end
else
begin
nNumberPop:=pNextValue^.Value;
end;
end;
end;
function nString2nList (String:^ char; var
Number:nNumber;):boolean;
begin
end;
begin
writeln ('Hello world');
end.
The errors I get:
ex1.pas: In function 'Nnumberisempty':
ex1.pas:17: invalid operands to binary =
ex1.pas: At top level:
ex1.pas:44: parse error before '^'
What causes these errors?
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
I have changed the string to start from 1:
String = packed array[1..256] of char;
var
Test:string;
begin
readln (Test);
end.
Now I get the following error:
ISO 7185 Pascal does not allow reading strings from
textfiles
So, how am I suppose to read a string?
Read a char one after another?
Another question, how do I mark the end of string?
Is there a special char for that, like '/0' in C?
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
It suppose to be:
String = packed array [0..255] of char;
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/