Firstly i know your gonna say "OMG this guy just want to make his homework using our help"
"Wow, this guy is so stupid not knowing this"

Yes, i dont know this.. and yes this is my homework..
i'm not asking a direct answer atleast just teach me while pointing out how to use this.
(explanation that i can understand no complex explanations please)

Here it goes.. how do you change vowels into a different vowel (ex. A turns to E) using strings think they call this piglakin i'm not hoping for someone to give the whole code
atleast point out how to make one.

Dani AI

Generated

This is vowel-substitution advice (A -> E etc.), not Pig Latin — already corrected that distinction. A simple, robust plan is: pick the vowel mapping you want; scan the string character by character; when you see a vowel replace it, preserving uppercase/lowercase; be careful with char vs string literals and with C library ctype functions.

A clear, correct C++11+ example that shows the mapping and preserves case:

#include <iostream>
#include <string>
#include <unordered_map>
#include <cctype>

int main() {
    std::string s = "Hello World";
    std::unordered_map<char,char> vowel_map = {
        {'a','e'}, {'e','i'}, {'i','o'}, {'o','u'}, {'u','a'}
    };

    for (char &ch : s) {
        unsigned char uc = static_cast<unsigned char>(ch);
        char lower = static_cast<char>(std::tolower(uc));
        auto it = vowel_map.find(lower);
        if (it != vowel_map.end()) {
            char repl = it->second;
            ch = std::isupper(uc) ? static_cast<char>(std::toupper(static_cast<unsigned char>(repl))) : repl;
        }
    }

    std::cout << s << '\n';
}

Notes and common pitfalls: was right to think per-character modification is appropriate, but avoid assigning string literals to a single character — use single quotes for chars. Always cast to unsigned char before calling std::tolower/std::toupper to avoid undefined behavior for negative char values. The snippet above works for ASCII; if you need to handle multi-byte UTF-8 characters or accented vowels, use a Unicode-aware library or process code points rather than raw bytes. Range-based loops require C++11 or later.

Recommended Answers

All 2 Replies

Well assuming that you have a string and you want to change it, you can
used this

std::string test="abcde";
test[4]="X";
std::cout<<"Test == "<<test<<std::endl;

The string class provides the operator[] which allows you to examine and change each letter in the string. That along with a loop will allow you to change the vowels in a string to anything you please.

If you get a little more sophisticated you can start using functions like find() etc. But start with a loop first.

If you get stuck, post the code you have ... hope this helps.

It's Pig Latin, not piglakin. Read this wiki article to see how to convert English words into pig latin. It will not give you the c/c++ code, but will show you what you have to do.

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.