Pig Latin

0

Hi ,I’m doing a program of Pig Latin but here I can’t put my first alphabet of each word at the end of it, can anyone help me.I don’t have to use any library. Thanks in advance.

#include<iostream>
using namespace std;

char * pigLatin(char *name, int size)
{
int j = 0;
int k = 0;
int m = 0;
int n = 0;
for (int i = 0; i < strlen(name); i++)
{
if (name[i] == ' ')
{
k++;
}
}
int newSize = strlen(name) + 2 * k-1 ;
char * newName = new char(newSize);
for (int i = 0; i < strlen(name); i++)
{
if (m < newSize)
{
while (name[i] != ' ' || name[i] == '')
{
if (m < newSize)
{
newName[m] = name[i];
++m;
i++;
}
}
}
if (m < newSize)
{
newName[m] = 'A';
newName[++m] = 'Y';
newName[++m] = name[i];
++m;
}
}
newName[m] = '';
for (int j = 0; j < newSize; j++)
{
cout<<newName[j];
}
return newName;
}
int main()
{
char *string = "I SLEPT MOST OF THE NIGHT ";
int size = strlen(string);
pigLatin(string, size);
return 0;
}
Tags: asked August 1, 2015

Your Answer