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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:51:09+00:00 2026-06-14T04:51:09+00:00

std::ifstream file_1(argv[1]); std::ifstream file_2(argv[2]); … std::string dummy_1; std::string dummy_2; … while(std::getline(file_1, dummy_1) || std::getline(file_2,

  • 0
std::ifstream file_1(argv[1]);
std::ifstream file_2(argv[2]);
...
std::string dummy_1;
std::string dummy_2;
...
while(std::getline(file_1, dummy_1) || std::getline(file_2, dummy_2)) // the problem
{
  ...
}

The condition behaves like the OR operator is evaluating the option on the right only if the file on the left reach the end (returning a FALSE) and it doesn’t evaluate them at the same time.

I know that the evaluation of a statement has nothing to do with the operator itself or with its own precedence rules, but my program it’s not supposed to work like I’m imaging with both statements being evaluated at the same time ?

  • 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-14T04:51:11+00:00Added an answer on June 14, 2026 at 4:51 am

    The OR operator is a short circuit operator, meaning that if one side evaluates to true the other side is never actually executed. If your intention is to have both sides of the OR evaluated then you might want to reconsider how your code is written.

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

Sidebar

Related Questions

i have the next code: std::string line; std::ifstream myfile (text.txt); if (myfile.is_open()) { while
std::ifstream sr(path.c_str()); if (!sr) throw runtime_error(Could not open file '+path+\'); sr.seekg(0, ios::end); streampos lastPos
I'm converting a project from vs2008 to vs2010 and getting linker errors for std:ifstream/ofstream
I am trying to do the following: template <class T> std::ifstream& operator>> (std::ifstream& fin,
Why does the following not work: #include <iostream> #include <fstream> #include <stack> std::stack<std::ifstream> s;
#include<iostream> #include<fstream> #include<cstdlib> #include<iomanip> using namespace std; int main() { ifstream in_stream; // reads
I'm using std::getline() to read lines from an std::istream-derived class, how can I move
I would like to compare a character literal with the first element of string,
I'm trying to update a random-access binary file using the std::iostream interface with separate
Possible Duplicate: How is std::iostream buffered? This might sound ridiculous, but how can I

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.