Hello, First of all I want to thank all the help with my posts.

I have a program where I have to convert a phrase from lower case to upper case, but I cannot use any of the toupper() isupper() functions and vice versa.

I think I almost got it, but I know my for loop for the conversion is incorrect.

Here is my code:

#include <iostream>
#include <string>
using namespace std;





int main()
{
    char beach[] = "Take me to Clearwater Beach!";
    cout << "Initial Phrase: " << beach << endl;

    for (char *i = beach; *i != '\0'; ++i)
    {

        if( i >= "a" && i <= "z")
        i += 32;
        ++i;

    }

    cout << "\n";
    cout << "New Phrase: " << beach << endl;



    return 0;

}

My for loop has to be incorrect, it's not doing any of the arithmetic.

Thanks again!

A character literal uses single quotes, string literals use double quotes. There's a difference, and it's rather significant. ;)

I figured that, but then I kept getting these errors:

C:\Users\""\Desktop\beach.cpp: In function int main()': C:\\Users\\""\\Desktop\\beach.cpp:18: invalid initializer C:\\Users\\""\\Desktop\\beach.cpp:21: no match forbasic_string<char,string_char_traits<char>,__default_alloc_template<false,0> > & != char'
C:\Users\""\Desktop\beach.cpp:24: warning: comparison of distinct pointer types string *' andchar *' lacks a cast
C:\Users\""\Desktop\beach.cpp:24: warning: comparison of distinct pointer types string *' andchar *' lacks a cast

You've inspired me to do a pony avatar ha ha

Compare this with your code and see if you can figure out why I made certain changes:

for (char *i = beach; *i != '\0'; ++i)
{
    if( *i >= 'a' && *i <= 'z')
        *i -= 'a' - 'A';
}

You've inspired me to do a pony avatar ha ha

Welcome to the herd. :D

So adding an int value of ASCII wouldn't work, you would subtract the actual char, I guess

Thank you by the way

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.