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 6750007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:45:27+00:00 2026-05-26T12:45:27+00:00

I am trying to open these two files and read their contents into two

  • 0

I am trying to open these two files and read their contents into two different arrays, but whenever I try and open them I get the unable to open file dialog? I don’t see anything incorrect but I am not a strong c++ user.

std::ifstream inFile;

inFile.open("fives.txt"); 
if (inFile.is_open()) 
{
    while (! inFile.eof() ) 
    {
        getline (inFile,line);
        fives[loop] = line;
        cout << fives[loop] << endl; 
        loop++;
    }
    inFile.close(); 
}
else cout << "Unable to open file";

inFile.open("search.txt");
loop=0;
if (inFile.is_open()) 
{
    while (! inFile.eof() ) 
    {
        getline (inFile,line);
        search[loop] = line;
        cout << search[loop] << endl; 
        loop++;
    }
    inFile.close(); 
}
else cout << "Unable to open file";
  • 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-05-26T12:45:28+00:00Added an answer on May 26, 2026 at 12:45 pm

    The files must exist in the current directory, where the current directory is the directory from which the program was executed (not necessarily the one where the executable is saved at).

    In your case, you saved the files with the resources, not with the resulting binary (I’m guessing you’re running from within the VC++, by default it sets the current directory to where the binary is stored), so the program cannot find them. Use either relative path to where the resources are, or copy the files you’re looking for into the directory you’re running from.

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

Sidebar

Related Questions

I am trying to merge two or more postscript files into one. I tried
I'm trying to add two image files into the solution, so they will be
I'm trying to read from two files, and generate output in a third. I
I trying to open C: directly with FileStream without success: new FileStream(C:, FileMode.Open, FileAccess.Read,
I'm trying to open a file and create a list with each line read
I'm trying to a somewhat sophisticated diff between individual rows in two CSV files.
I'm trying to read a BMP file in Python. I know the first two
What I'm trying to do with FileStream in C#/.NET is to open two streams:
I'm trying to write a program that merge two or more .dat files in
Is there a better way than simply trying to open the file? int exists(const

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.