Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, can anyone help me with the following program? The problem seems to be in variable c, but it doesn't seems wrong to me. Can anyone please help me?

The text that the program reads is like this

3 2
1 2
1 3
1 2

Where 3 is n , so the procedure the program must be done 3 times, so as all the nums., will be read.

The message of the compiler is the following
the program.txt(33,1)Error: Wrong numbers of parameters specified for call to "space".
the program.txt(65)Fatal:There were 1 errors compiling module, stopping
the program.txt(0)Fatal:Compilation aborted

Delphi
Program filetext;
Uses sysutils;
type
ca=String[1];
Var
a,j:array[1..100000] of String;
c:array[1..100000] of ca;
v:String[1];
n:String;
d:String;
i,m:Integer;
f:Text;

Procedure thenum ; //Reads the first num. before space.//
Begin
repeat
Read (f,a[i]);
Write(a[i]);
until (a[i]=' ');
End;

Procedure sth ; //Reads the num. after the space.//
begin
while not seekEoln and eof(f) do
begin
read(f,j[i]);
Write(j[i]);
end;
End;

Procedure theprogram;
begin
thenum;
space;
sth;
end;

Procedure space; //procedure that reads the space so as to proceed to the next num. and read                it.//
begin
Read(f,c[i]);
Write(c[i]);
end;

begin  //main program.//
Assign(f,'textfile.txt');
Reset(f);
repeat
Read (f,n);
Write(n);
until (n=' ');
Read(f,v);
Write(v);
while not seekEoln and eof(f) do
begin
read(f,d);
Write(d);
end;
StrToIntDef(n,m);//puts the value of n in an integer.//
for i:=1  to m  do
theprogram;
if eof(f) then;
Close(f);
Readln;
End.
Posted
Updated 25-Jan-14 9:34am
v4
Comments
André Kraak 25-Jan-14 12:48pm    
Please indent your code it is hard to read.

1 solution

If the code as you posted, than you have a syntax error (case) here:
Delphi
procedure space;
begin
Read(f,c[i]);
Write(c[i]);
end;

It should be
Delphi
Procedure space;
begin
Read(f,c[i]);
Write(c[i]);
end;
 
Share this answer
 
Comments
Member 10538783 25-Jan-14 15:31pm    
Thanks for your help, but i tried to compile it and it still has the error message.
Kornfeld Eliyahu Peter 25-Jan-14 15:35pm    
theprogram calls space - replace there order in code...or use forward declaration
Member 10538783 25-Jan-14 15:44pm    
Thanks for your help,Well, i'm not exactly sure that you meant that, but has the problem have to do with that the procedure theprogram runs every time each procedure inside it i times and then the next procedure i times, and not each procedure for one time and then the next one for i times, so that's why there is a problem with space? Or that's maybe anothr problem?
Kornfeld Eliyahu Peter 25-Jan-14 15:50pm    
The problem is order...
You have thesum, sth, theprogram and space.
As theprogram calls space it have to see it to build the proper calling, but as space declared after theprogram it can't see it. You can reorder you procedures like this: thesum, sth, space, theprogram or use forward declaration...
http://en.wikipedia.org/wiki/Forward_declaration
Member 10538783 25-Jan-14 15:54pm    
O.K., thank you very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900