English 中文(简体)
创建笔译员; 需要从文本档案中适当插入
原标题:Creating translator; Need to properly insert from a text file

关于我的文科班,我们被派到这里,用文字文件制作一个 english to spanish translation:

至今,我转而去了,但当我执行该方案时,言辞已经ming,我说,每条线上都用多字眼,就是破坏它。

#include<iostream>
#include<string>
#include<fstream>
using namespace std;

class transl
      { private:
            class word
                  { public:
                        string eng_word,
                               spa_word;
                        word * next,
                             * prev;    

                        word(string engl_word, string span_word, word * next1 = NULL, word * prev1 = NULL)
                        {   eng_word = engl_word;
                            spa_word = span_word;
                            next = next1;
                            prev = prev1;   }
                  };

            word * head,
                 * tail;

        public:
            transl::transl()
            {   head = NULL;
                tail = NULL;    }

            transl::~transl()
            { word * wordPtr, * nextWord; 
                     wordPtr = head;

                     if(head == NULL)
                        return;

                     while(wordPtr != NULL)
                          { nextWord = wordPtr->next;
                            delete wordPtr;
                            wordPtr = nextWord; }
            }

            void insert(string engl_word, string span_word)
            {   if(head == NULL)
                   head = new word(engl_word, span_word);

                    else
                    {   word * wordPtr;
                        wordPtr = head;

                        while(wordPtr->next != NULL)
                        {     wordPtr->next->prev = wordPtr;
                              wordPtr = wordPtr->next;  }

                        wordPtr->next = new word(engl_word, span_word);
                        cout << wordPtr->next->eng_word << "    " << wordPtr->next->spa_word << endl; } 
            }

            string search(string engl_word)
            {   return "Hello"; }

            };

int main()
    {   ifstream inFile;    inFile.open("dictionary.txt");
        string engl_word, span_word;
        transl test;

            if (!inFile)
            {   cout << "ERROR! CANNOT LOCATE DICTIONARY!" << endl;
                system("pause");
                return 1;   }

            cout << "Loading Dictionary:  ";

                while(inFile >> engl_word >> span_word)
                {   test.insert(engl_word, span_word);  }

            cout << "Done!" << endl;
            system("pause");
            system("CLS");

            cout << "Translate: ";
             cin >> engl_word;

            cout << "The translation of " << engl_word << " is " << test.search(engl_word) <<  .  << endl;

            system("pause");
        return 0;   }

例如:

peor    wound
la    herida
wounded    herida
Done!
Press any key to continue . . .

任何人是否知道适当插入价值观的程序

问题回答

<条码> Ptr->next->prev = 字数;是多余和混淆的。 你正在寻找名单的结尾,但正在对名单进行修改。

您将撰写新字的序号。

然而,真正的问题是阅读字典。 页: 1 阅读了两个白天空间限制清单。 然而,被认可的条目不是白天限制的,而是在这条线的其余部分。 虽然你可以读到网站>>,但你需要诸如getline(cin, range_word )等内容,以平整口头表述。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签