Hey guys, learning pascal here. I'm new to this programming thing and i've got a problem that's been bugging me.
I've gotta write a procedure called print_words which receives a string as a parameter, and print all the words contained in the that string. Consider all the characters other than space as components of a word. So if i type:
This is a test 12$%ab
the program must return me:
This
is
a
test
12$%ab
Would anyone help me?
Name:
Anonymous2012-11-20 17:45
So far i could make it work outside a procedure, but i can't seem to put it inside.
Name:
Anonymous2012-11-20 17:45
test to see if i can add my code
Name:
Anonymous2012-11-20 17:46
Here's what I've got so far:
program words;
uses crt;
var
phrase :string;
word:string;
letter :char;
x :integer;
begin
clrscr;
phrase:='';
word:='';
x:=1;
repeat
write('type a phrase: ');
readln(phrase);
until phrase<>'';
while x<=length(phrase) do
begin
letter:=phrase[x];
case letter of
'a'..'z','A'..'Z':
begin
word:=word+letter;
repeat
x:=x+1;
letter:=phrase[x];
word:=word+letter;
until (letter=' ') or (x=length(phrase));
writeln(word);
word:='';
end;
end;
x:=x+1;
end;
writeln;
readkey;
end.
You ``bumped'' after 11 minutes? Do you understand how this place works?
Name:
Anonymous2012-11-20 18:09
Been to /g/
Like i said, i'm pretty new to this and I've got the worst teacher money can buy. I'm broke as fuck, unemployed and I'm trying my best here to learn this thing.
If this is so easy for you could you kindly give me some help?
>>8
I'm unemployed, live in a third world country and pay my Internet/electricity bill by selling shitty enterprise applications I learned to program back when I lived with my family. Stop using shitty questions and read the damn tutorials on the Internet.
Name:
Anonymous2012-11-20 18:15
Yeah i know, i just gotta make it work within a procedure, and not in the body of the program.
>>11
*shitty excuses
I'm mad at these first world spoiled kids
Name:
Anonymous2012-11-20 18:19
>>13
Joke's on you, i live in Brazil.
Dude, I'm a 36 years old broke advertiser.
I lost my house, my partner in my agency died, my woman left me (because I'm broke as fuck). No lies, no excuses, I'm trying to learn something new to pull myself outta this situation.