Quote:
Originally Posted by Chong View Post
Hi
Copy and paste the following program to see if it does what you want. Your original sample program does not do that job!
Best regards
Chong
Code:
//#include <stdio.h>
#include <iostream.h>
#include <string.h>
 
#define SIZE 90
 
void convertPigLatin(char *word,char *p);
 
 
 
main()
 
{
 
        char word[SIZE];
 
    char piglatin[SIZE];
 
    //printf("Input: ");
    cout << "Input:";
 
    //scanf("%s", word);
 
    cin >> word;
 
    convertPigLatin(word,piglatin);
 
    //printf("Pig Latin: %s\n", piglatin);
    cout <<"Pig Latin: " << piglatin << '\n';
 
}
 
 
 
void convertPigLatin(char *word, char *p)
 
{
 
    char *pig_latin="ay";
 
    char *after, *before;
    char *tmp=p;
    char tmp_word[SIZE];
 
    strcpy(tmp_word,word);
    strcpy(p,word);
    //*(p+strlen(word))=NULL;
 
    while (strchr("aeiouAEIOU",*tmp_word) == NULL)
 
    {
 
        char consonant=*tmp_word;
 
        before=tmp_word+1;
 
        while (*before)
 
            *(p++)=*(before++);
 
        *p=consonant;
        p=tmp;
        strcpy(tmp_word,p);
    }
 
    strcat(p, pig_latin);    
 
}
Hi thank u so much!
I have tried to debug your code but i got the error C1083: Cannot open include file: 'iostream.h': No such file or directory and IntelliSense:cannot openn source file "iostream.h", cout is undefined, cin is undefined.

Used Mircosoft Visual C 2010 Express to debug it
coderzone, shabbir likes this