new poster, need help with a pig latin translator. translation doesn't work properly, any tips or troubleshoots?
sorry if it seems long...
any help would be greatly appreciated

#include <iostream>
#include <string>

using namespace std;

bool isVowel(char ch);
string rotate(string pigStr);
string pigLatinString(string pigStr);

int main () 
{
	char Piggy[1024];

	string str;
	cout << "Enter a string:";
	cin.getline(Piggy, 1024);
	str = Piggy;
	cout<<endl;

	cout << "The pig Latin form of" << str << "is:"<< pigLatinString(str) << endl;
	
	return 0;
}

bool isVowel(char ch) 
{
	switch (ch) 
	{
	case 'A': case 'E': 
	case 'I': case 'O':
	case 'U': case 'Y': 
	case 'a': case 'e':
	case 'i': case 'o': 
	case 'u': case 'y': return true;
	default: return false;
	};
}//end isVowel

string rotate(string pigStr) 

{
	string::size_type len=pigStr.length();
	
	string rStr;
	
	rStr=pigStr.substr(1,len-1)+pigStr[0];
	
	return rStr;
}

string pigLatinString(string pigStr) 

{
	string::size_type len;

	bool foundVowel;

	string::size_type counter;
	
	if (isVowel(pigStr[0]))
	
		pigStr=pigStr+"-way";
	
	else 
	{//didn't start with a vowel
		
		pigStr = pigStr + "-";
		pigStr=rotate(pigStr);
		len=pigStr.length();
		foundVowel=false;
	
	for (counter = 1; counter<len-1; counter++)
	
	if (isVowel(pigStr[0]))
		
		{
			foundVowel=true;
			break;
		}

	else
		
			pigStr=rotate(pigStr);
	
	if (!foundVowel)
	
		pigStr=pigStr.substr(1,len)+"-way";
	
	else

		pigStr = pigStr + "ay";
	}
	return pigStr;

}

here is sample output

The pig Latin form ofToday is a great dayis:oday is a great day-Tay
Press any key to continue . . .

it seems that the program is treating the whole sentence as one word...

I think that it is important that we focus on the origins of pig latin and how it is properly implemented:

Pig Latin is a language game of alterations played in English. To form the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed (for example, trash yields ash-tray and plunder yields under-play). The purpose of the alteration is to both obfuscate the encoding and to indicate for the intended recipient the encoding as 'Pig Latin'. The reference to Latin is a deliberate misnomer, as it is simply a form of jargon, used only for its English connotations as a 'strange and foreign-sounding language'; it could also be because the transformed words sound similar to Latin.

Rules and variations
The usual rules for changing standard English into Pig Latin are as follows:

In words that begin with consonant sounds, the initial consonant or consonant cluster is moved to the end of the word, and "ay" is added, as in the following examples:
beast → east-bay
dough → ough-day
happy → appy-hay
question → estion-quay
star → ar-stay
three → ee-thray
In words that begin with vowel sounds or silent consonants, the syllable "ay" is added to the end of the word.
Transcription varies. A hyphen or apostrophe is sometimes used to facilitate translation back into English. Ayspray, for instance, is ambiguous, but ay-spray means "spray" whereas ays-pray means "prays."

Yeah, i got that same definition from the prof in the assignment listing, I originally used cin, but that only read up to the first space, so I used the cin.getline to attempt to fix that problem, but the program treats the entire sentence as one word, any suggestions to clean up my code?

You'll probably have to take in the entire line using getline() then parse the line up into individual words:

#include<cstring>

swine[100];
char* words[30];

cout << "Enter line: ";
cin.getline(swine, 100);

//break it up
int =0;
words[0] = strtok(swine, ' ');
while(swine[i] != NULL)
{
     words[i] = strtok(NULL, ' ');
     i++;
}

//Now you have the ability to do something like this
for(int i=0; i<word_count; i++)
{
     to_piglatin(words[i]);
}

//Now copy all the pig latinized words back into a single buffer
char buffer[100];
for(int i=0; i<word_count; i++)
{
     strcat(buffer, words[i]);
     strcat(buffer, ' ');
}

Here is the documentation for strtok()

Thanks for the help, greatly appreciated!

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.