Pig Latin

A common topic i'm sure. I've managed to make my program compile but it comes up with a very strange error in the console when i try to use it. feel free to correct my notes and what not im a complete newbie.

the error is "unknown pseudo relocation protocol versoin %d.
ngw runtime failure."

i have tried to find an answer but i do not understand them, as far as i can comprehend is somthign to do with a char somewhere.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  #include <iostream>                                                     //include cin/cout and other functions
#include <sstream>                                                      //stringstream functions used for parsing a string
#include <string>                                                       //string related functions
#include <algorithm>                                                    // manipulation functions such as min/max and changing strings
#include <iterator>                                                     // used to sort through the vector string list
#include <vector>                                                       // functions for vectors

using namespace std;

vector<string> parse(const string &s, char delim){                      // the parsing function

  vector<string> elems;                                                 // creating a vector container
    stringstream ss(s);                                                 // creating a stringstream, needed for the parsing
    string item;
    while(getline(ss, item, delim))
    {
        elems.push_back(item);                                          // moving through each word
    }
    return elems;
}

int main(){

    cout << "Enter a Phrase" << endl << "--------" << endl;

    string input = "";
    string vowels = "aeiou";
    string piglatinword = "";
    int z = 0;

    getline(cin, input);                                                // more efficient than cin can perform more operations on the input
    vector<string> sentance = parse(input, ' ');                        // parsing the input string  by ' ' and placing it in a vector container
    vector<string>::iterator itr;                                       // turns the vector container into an iterator

    for(z = 0, itr = sentance.begin(); itr != sentance.end(); z++, itr++){  // each word in the iterator is assigned to the string word as they are processed

        string word = *itr;

        for(z = 0; z < vowels.length(); z++){                               // work through all the letters in the vowel string

            if(word[0] == vowels[z]){                                       // if the first letter is a vowel

                word + "ay";
                piglatinword = word;
        }
    }

        for(z = 0; z < vowels.length(); z++){                               // work through all the letters in the vowel string

            if(word[0] != vowels[z]){                                       // if the first letter is a vowel

                piglatinword = word.substr( 1 );

                piglatinword += word[ 0 ];

                piglatinword += "ay ";
            }
        }
    }
    for(unsigned int i = 0; i < piglatinword.size(); i++){                     // this is listing the words from the vector

    cout << piglatinword[i] + " ";

    }

    return 0;
}

what compiler you using?
I don't get that message. (vs 2013)

read this:
http://stackoverflow.com/questions/9471634/runtime-failure

It's not the same thing, but i'm willing to bet you have a similar problem.
Last edited on
gnu gcc compiler, the defualt one from code:blocks, interesting that you didnt have that problem, does it work properly for you? i will read that in a bit i have to paperwork to do, then ill get back to you. Thanks
the page you directed me to seems to indicate that either of the for() lines could be responsible, something to do with characters not having a value? im not really sure i understood it all that well.
[Solved]
Started from the beginning;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;

vector<string> split(const string &s, char delim) ;

int main(int argc, char *argv[])
{
  cout << "Type a sentence" << endl << "---------------" << endl;

  string sentence = "";
  string vowels = "AEIOU";
  string pigword = "";

  unsigned int j = 0;
  unsigned int i = 0;
  unsigned int x = 2;

  getline(cin, sentence);
  istringstream iss(sentence);

  vector<string> words;
  copy(istream_iterator<string>(iss),
             istream_iterator<string>(),
             back_inserter<vector<string> >(words));

 vector<string>::iterator itr;

 for(i = 0, itr = words.begin(); itr != words.end(); i++, itr++){
    string aword = *itr;

  for(unsigned int i = 0; i < words.size(); i++)
  {
    for(j = 0; j < vowels.length(); j++){
            if( x < aword.length()){
            if(toupper(aword[0]) == vowels[j]){
                aword + "ay";
                pigword = aword;
            }

            else{
                pigword = aword.substr( 1 );
                pigword += aword[ 0 ];
                pigword += "ay ";
                }
            }
            else{
                pigword = aword;
            }
        }
    }
    cout << pigword +" ";
  }

  return 0;
}

vector<string> split(const string &s, char delim)
{
  vector<string> elems;
    stringstream ss(s);
    string item;
    while(getline(ss, item, delim))
    {
        elems.push_back(item);
    }
    return elems;
}
Topic archived. No new replies allowed.