PROGRAM DOESNT GIVE ANYTHIN AS AN EXIT - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# PROGRAM DOESNT GIVE ANYTHIN AS AN EXIT

Posts: 5Member
I POST MY PROGRAM... JUST TELL ME WHERE I AM WRONG...

var
i,j,k,l,count2,m:integer;
s:string[100];
a:string[20];
begin
while not eof do
begin
j:=0;
While j<=61 do
begin
i:=1;
repeat
until a[i]<>' ';
while (a[i]<>' ') and (i<20) do
begin
i:=i+1;
end;
if 60-j>=i+1 then
begin
j:=j+1;
s[j]:=' ';
for k:=1 to i-1 do
begin
j:=j+1;
s[j]:=a[k];
end;
if a[i]<>' ' then
begin
j:=j+1;
s[j]:=a[i];
end;
end
else
begin
count2:=60-j;
While count2>0 do
begin
l:=60;
while (l>=1) do
begin
if s[l]=' ' then
begin
insert(' ',s,l);
count2:=count2-1;
end;
l:=l-1;
end;
end;
end;
end;
for m:=1 to 60 do write(s[m]);
writeln;
end;
end.

• Posts: 438Member
: I POST MY PROGRAM... JUST TELL ME WHERE I AM WRONG...
:
Please be more specific as to what the problem is.

• Posts: 5Member
• Posts: 5Member
• Posts: 5Member
I WILL POST YOU A NEW PROGRAM OF MINE MADE TO DO THE SAME WORK. FINALLY IT DOESNT WRITE ANYTHING ON THE SCREEN TOO AND IT TERMINATES WRITIN BAD FILE DESCRIPTOR

var
i,j,l,count,k:integer;
s:array[1..61] of char;
a:array[1..21] of char;
begin
while not eof do
begin
j:=1;
while j<=61 do
begin
repeat
until a[1]<>' ';
i:=1;
while (i<20) and (a[i]<>' ') do
begin
i:=i+1;
end;
if i-1<=60-j+1 then
begin
for k:=1 to i-1 do
begin
s[j]:=a[k];
j:=j+1;
end;
if i-1<60-j+1 then
begin
s[j]:=' ';
j:=j+1;
end;
end
else
begin
count:=60-j+1;
k:=j-2;
while count>0 do
begin
if s[k]=' ' then
begin
for l:=60 downto k+1 do
begin
s[l]:=s[l-1];
count:=count-1;
end;
k:=k-1;
end;
end;
j:=1;
end;
end;
for l:=1 to 60 do write(s[i]);
writeln;
for l:=1 to i do
begin
s[l]:=a[l];
j:=j+1;
end;
s[j]:=' ';
end;
end.

• Posts: 438Member
Complex!

I've worked with it for a while and all I can say is that I ams certain that you are stuck in a loop. I strongly suspect it is :
[code]
while j<=61 do
[/code]
Looking at the code suspect that the condition [b]j <= 61[/b] will ever fail.

But it may be :
[code]
repeat