BattleCrazy, in case you missed the detail from previous posts, after you move "convert" out from inside the "main" function, you have one more problem:
The ';' character at the end of "convert(string &s)" should not be there when the code defines the function.
What you've typed out is the declaration. They are two different but related notions.
The declaration is just the signature, like
void convert( string & );
The declaration, in case that's not clear, is like an entry in a table of contents. More specifically, it "declares" the function will come later in the code (or in another CPP file, called a translation unit, or compilation unit).
The definition includes the code itself, in brackets, like this:
1 2 3 4 5 6 7
|
void convert( string & s)
{
for (int i = 0; i < s.length(); i++)
{
s[i] = toupper(s[i]);
}
}
| |
Note that there's no ';' in the first line of that code.
Now, if you put the definition BELOW the main function, you'll get an error when you call convert, but that's simple to deal with.
You need to place a declaration ABOVE the main function.
C/C++ are "one pass compilers", and so such declarations (sometimes called forward declarations) are required to inform the compiler this function will be given later.
You'll get the hang of it as you practice.