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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:20:22+00:00 2026-06-18T01:20:22+00:00

I have a courses0.dat file with a single 4 on line 1 that I

  • 0

I have a courses0.dat file with a single 4 on line 1 that I want to extract with my ifstream program:

void processEnrollments (std::istream& courseFile);

int main (int argc, char** argv)
{

// Take input and output file names from the command line
ifstream coursesIn (argv[1]);

return 0;
}

void processEnrollments (istream& courseFile)
{
int numCourses;
courseFile >> numCourses;

cout << numCourses;

// Create the arrays we need
//!! Insert your code here
}

when I run

program courses0.dat

my test is cout’ing a 32767 instead of a 4. My .dat file is in the same directory as my executable.

any clue as to what is going on?

thanks

  • 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-18T01:20:23+00:00Added an answer on June 18, 2026 at 1:20 am

    Check for errors! Try to use the full path to the file when you pass it as an argument.

    My guess is courseFile >> numCourses; fails because ifstream coursesIn (argv[1]) doesn’t find or can’t access the file.

    Try this

    if( courseFile >> numCourses )
        cout << numCourses;
    

    Does it output anything then?

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

Sidebar

Related Questions

I have two Entities University courses Course students i want to access all the
I have a Dataset that contains tables from a university database, two(actually more) of
I have taken some courses in c/c++ and I understand that int type size
I have a table called Courses with two columns dept_code and course_code that are
I have always read that Cassandra is good if your application changes frequently and
I'm trying to match all urls that have courses/wwwwddd and nothing after the dd.
I have 6 different courses, and I want students to rank them by degree
Assuming that if the error's spotted in the .o file that it's the linker's
I have this code using Harvard API that thakes all the CS courses and
I have one Sharepoint list that contains training courses and duration (in hours). 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.