Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Noun Issue..

  • 22-10-2011 9:44pm
    #1
    Closed Accounts Posts: 2,663 ✭✭✭


    cant figure out how to get this to work.

    every thing seems find but i cant get if some one enter some thing other then y s ch sh

    add a 's' to the end of it.
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    
    using namespace std;
    
    void findPlural(char *  input, char* &plural);
    
    void findPlural(char *  input, char* &plural)
    
    
    {
        int lenght;
        
        
        lenght = strlen(input);
        
    
        if (input[lenght -1] == 'y') 
        {
            strcpy(plural,input);
            input[lenght -1] = 'i';
            strcat(plural, "es");
            
        } 
        
       else if (input[lenght -1] == 's'|| 'ch' || 'sh')
        {
           strcpy(plural,input);
           input[lenght -1] = 'e';
            strcat(plural, "s");
        }
        else if (input[lenght -1] != 's'||'ch'||'sh'||'y')
        {
            strcpy(plural,input);
           input[lenght -1] = 's';
            strcpy(plural,input);
        }
        
    }
    int main ()
    {
        char noun[30];
        
        char * pural;
        
        
        pural = new char[30];
        
        cout << "Enter a noun" ; 
        cin >> noun;
        
       findPlural(noun, pural);
        
        cout << " The Plural of " << noun << " is " << pural << endl; 
        
        return 0;
    }
    

    its doing my head in.... also for some reason the Noun should read out what i type in and the pural should have Either s,es, ies to to end of the String/Char..


Comments

  • Registered Users, Registered Users 2 Posts: 1,235 ✭✭✭Odaise Gaelach


    Can you give us some examples of what you input and what you get back? :)


  • Closed Accounts Posts: 2,663 ✭✭✭Cork24


    when i enter dog it should have dogs but it prints out doges


  • Closed Accounts Posts: 10,833 ✭✭✭✭Armin_Tamzarian


    I'm guessing that English isn't your first language?


    Try changing this

    else if (input[lenght -1] == 's'|| 'ch' || 'sh')



    to this

    else if (input[lenght -1] == 's' || (input[length-2] == 'c' && input[length-1] == 'h'))
    {
    strcpy(plural,input);
    strcat(plural, "es");
    }


  • Closed Accounts Posts: 2,663 ✭✭✭Cork24


    I'm guessing that English isn't your first language?
    :confused::confused::confused::confused::confused:

    Either way thanks that done the trick for it!


Advertisement