Delphi problem.

boggom

Well-Known Member
Joined
Jan 18, 2009
Messages
261
Reaction score
61
Location
George
I was hoping somebody could help me. I need to code an application in Delphi (Borland Delphi 7) that checks wether a particular vowel occurs in a text input from user. The application then checks in which position this vowel is. I've managed this but now I need to alter this so that it also counts the number of occurrences (of the particular vowel) in the input string.

It's for a UNISA assignment for Friday so please, can anybody help me with this?
 
Code:
function Occurs(const str: string; c: char): integer;
  // Returns the number of times a character occurs in a string
  var
    p: PChar;
  begin
    Result := 0;
    p := PChar(Pointer(str));
    while p <> nil do begin
      p := StrScan(p, c);
      if p <> nil then begin
        inc(Result);
        inc(p);
      end;
    end;
  end;
 
Dude, you can't really have people post answers to your assignments online! How are you gonna learn how to do it yourself?! :eek:
 
Thanks for the help Kloon, I couldn't get it working in the part that I already done... :o
Thanks for the comments other guys. :confused:
 
Top
Sign up to the MyBroadband newsletter
X