Link to home
Start Free TrialLog in
Avatar of ny971181
ny971181

asked on

Borland C++ String question

I need to create a function called MyStringFunct which accept 2 built-in strings(character arrays terminated by '\0') as parameters and returns an integer.

int MyStringFunct( char * parm1, char * parm2 )

The program should process according to the following:

Parm1          Parm2         Processing               Return value
"Initialize"   "Any Text"  Store Parm2 in a static              -1
                                      variable local to
                                      MyStringFunct

"Vowels"     NULL                                          No. of vowels
                                                                       in the static
                                                                       variable.

"Consonants" NULL                                      No. of conso-
                                                                      nents in the
                                                                      static variable.

Note: Be sure the function should work no matter what order the above calls are made.

More: How to change the parm1 to be a pointer to a function. Implement the same actions using different functions for "Init", "Vowel" etc..

Could you please write me some code so I can work on this exercise in my book?

Thanks
Chris Lee            
ASKER CERTIFIED SOLUTION
Avatar of yonat
yonat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ny971181
ny971181

ASKER

It looks fine but is it true that it has to have a main() in a program?

Chris Lee

Urgent!

int main()
{
    char buf[MAX_TEXT_LEN];

    for(;;) {
        cout << "Enter string to analyze\n";
        cin >> buf;
        cout << '\n';
        MyStringFunct("Initialize", buf);
        cout << "The number of vowels is " <<
            MyStringFunct("Vowels", NULL) <<
            ", and the number of consonants is " <<
            MyStringFunct("Consonants", NULL) << ".\n";
    }

    return 0;
}

thanks a lot

chris