Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have to make a list of movies in the command prompt for c++. Then the user needs to type in a group of letters that then the computer finds in the list of movies, and prints out the number of times that group of letters is mentioned.

What I have tried:

this is the code my instructor gave us
C++
cout << "Words beginning with 'ca': " << endl;
    for (int i = 0; i < words.size(); i++)
    {
        if (words[i].substr(0, 2) == "ca")
            /// OR:  words[i].find("ca") == 0
        {
            cout << words[i] << endl;
        }
        total += words[i].length();
    }
Posted
Updated 10-May-17 0:58am
v2
Comments
Dave Kreskowiak 24-Apr-17 19:20pm    
And the question would be ..... ?
Member 13149598 24-Apr-17 19:38pm    
can i put a prototype and definition in a while loop?
[no name] 24-Apr-17 19:42pm    
A prototype and definition of what? Did you ask your teacher? We aren't the ones that know anything about your homework.
Member 13149598 24-Apr-17 19:46pm    
My teacher has only taught us(The students) how to make a numbered list using a prototype and definition. He wants us to make a list of movies that are numbered. How would I do that?
[no name] 24-Apr-17 19:53pm    
Well I have no idea.
I am not your teacher so I don't what your teacher told you.
I know what a prototype and a definition are but I am not sure that you do and I have no idea what you think a prototype and a definition relates to your question.
What you are saying makes no sense at all.
You didn't answer either one of my questions.


1 solution

No you shouldnt. Constant should be global and at the top of a source file and with some commands, upper letters for good coding practice. Write always code in "reuse quality".
C++
// Prefix is recommanded
const char *PREFIX_MOVIE = "ca";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900