Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:07:01+00:00 2026-06-05T08:07:01+00:00

void getBookData(bookType books[], int& noOfBooks) { ifstream infile; string file = bookData.txt; infile.open(file.c_str()); if

  • 0
void getBookData(bookType books[], int& noOfBooks)
{
    ifstream infile;
    string file = "bookData.txt";
    infile.open(file.c_str());
    if (infile.fail()) {
        cout << "No file found!" << endl;
        infile.clear();
    }
    while (true) {
        string line;
        getline(infile, line, '\r');
        if (infile.fail()) {
            break;  
        }
        cout << "Line: " << line << endl;
    }
    infile.close();
}

I’ve tried putting the file in every location I can think of, but somehow it’s not loading in. Or, more likely, I’m doing something else wrong. This isn’t anything like what the end result of my code is supposed to be like, right now I’m just trying to read out my file line by line.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:07:02+00:00Added an answer on June 5, 2026 at 8:07 am

    I guess you really need help debugging why this is happening to you.

    Try adding some more code to your routine to help you determine what is going on. One thing to try is to call getcwd.

    #include <unistd.h>
    
    ...
    char buf[PATH_MAX];
    std::cout << "cwd: " << getcwd(buf, sizeof(buf)) << std::endl;
    ...
    

    This should report to you where your program thinks it is running from.

    Start with that first, and I am guessing the next steps will become obvious to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

void FileManager::CloseFile(File * const file) { for (int i = 0; i < MAX_OPEN_FILES;
void foo(void **Pointer); int main () { int *IntPtr; foo(&((void*)IntPtr)); } Why do I
void trim(string &str) { string::iterator it = str.begin(); string::iterator end = str.end() - 1;
void weight_data::rev_seq(string &seq){ //TODO std::reverse(seq.begin(), seq.end()); } In this C++ method, I think this
void merge(vector<int> dst,vector<int> first,vector<int> second) { int i=0,j=0; while(i<first.size()&&j<second.size()) { if(first[i]<second[j]) { dst.push_back(first[i]); i++;
void max_idxs(vector<int> &pidxs){ vector<fragment *> ids; max_ids(ids); for(size_t i = 0; i < ids.size();
void getnums(int *a, int *b); int main() { int a; int b; int c;
void* myfunction() { char *p; *p = 0; return (void*) &p; } I know
void f(int){} typedef void (*f_ptr)(int); struct Functor{ void operator()(int){} }; struct X{ operator f_ptr(){
void openUpNow(FILE *x, FILE *y) { x = fopen(xwhatever, r); y = fopen(ywhatever, r);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.