English 中文(简体)
档案能够开张,但不会归还任何东西? [闭门]
原标题:File is able to open but not returning anything? [closed]

这个问题是由无法再复制的打字或问题引起的。 虽然类似的问题可能包括,但以不大可能帮助未来的读者的方式解决了这一问题。

Closed 9 years ago.

I m 存在试图从txt档案中接线的问题。 我在另一部法典和文件中使用了类似的算法,似乎没有任何问题(所有线都印制)。 然而,当我尝试使用一条线(通常)时,我有直线线=“”。 我的界线不是空洞的,我事先要检查一下档案是否开立。 以下是我方案的职能。 谁能提供某种帮助? 感谢!

我正试图审理A案。

  void Database::LoginMenu(string code)
  {
    cout << endl;
    cout << "Thank You for Login In, Would You Like To..." << endl;
    cout << "====================================================" << endl;
    cout << "A. View your registration information" << endl;
    cout << "B. Search for others" << endl;
    cout << "C. Search for Upcoming" << endl;
    cout << "D. Enter the Database" << endl;

    char choice, YN;

    cout << endl;
    cout << "Please choose an option: ";
    cin >> choice;

    switch(choice)
    {
    case  A :
        {
            ifstream myfile("RegistrationInfo.txt");
            string line;
            if(myfile.is_open())
            {   
                while(!myfile.eof())
                {
                    getline(cin, line);

                    if(line[5] ==  : )
                    {
                        line = line.substr(7, line.size());
                    }
                    if(line == code)
                    {
                        while(!line.empty())
                        {
                            cout << line << endl;
                        }
                    }
                }
            }   
            cout << "Would you like to return to the menu? (Y/N)";
            cin >> YN;      

            if(YN ==  Y )
            {
                LoginMenu(code);
            }

            myfile.close();
        }
        break;
    case  B :
        {
            ifstream filein("RegistrationInfo.txt");
            string temp, YN, enteredInfo;
            int n = 0;

            cout << "Who do you wish to search for? :";
            cin >> enteredInfo;

            while(!filein.eof())
            {
                getline(cin, temp);
            }
        }
        break;
    case  C : upcomingComps();
        break;
    case  D : DatabaseMenu();
        break;
    }
  }

这里有几条线构成我的 t。

  • CCode: abd50896
  • Names: TomMullen NicoleLaBerge
  • Compt: Rutgers DanceSport 2012
  • Level: Newcomer
  • Dance: Tango Waltz Quickstep Rumba ChaCha Jive
最佳回答

建议使用我的档案作为第一种论点,而不是星号——getline(myfile, Line)——因为焚化物代表了不打开的档案。

问题回答

最为明显的是,你打开了档案,但你重新阅读。 Try changing cin into myfile.





相关问题
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?

热门标签