[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

upcase statement

a users inputs a string such as
(the cow jumped over the moon)
how can i convert this string or any other string so that the first letter of each word is turned into uppercase
(The Cow Jumped Over The Moon)

cheers
gandalph
0
GANDALPH
Asked:
GANDALPH
  • 2
1 Solution
 
_lychee_Commented:
i suppose words are separated only by space (or spaces)... then the following should work: (i is integer, s is a string, and b is a boolean)

b:=true;
for i:=1 to Length(s) do begin
   if (b) then begin
      if (s[i]<>' ') then begin
         s[i]:=UpCase(s[i]);
         b:=false;
      end;
   end else begin
      if (s[i]=' ') then b:=true;
   end;
end;
0
 
GANDALPHAuthor Commented:
hello lychee

i am not sure if i have awarded you your well deserved points

i am new to the web and new to programming so things at the moment are a little bit confusing

i suppose with time i will get better

your program suggestion worked great

i hadnt come across the boolean statement before so it took me a bit of time to look it up and work it out from there

but it does the job and i am greatfull

cheers

gandalph
0
 
_lychee_Commented:
just keep at it :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now