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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:25:46+00:00 2026-06-04T04:25:46+00:00

I have no clue whatsoever as to what would be doing this #include fstream

  • 0

I have no clue whatsoever as to what would be doing this

#include "fstream"
#include "iostream"

using namespace std;

#define out(a) cout << #a << ": " << a << '\n'

void print(string s)
{
  cout << s << '\n';
}

 int main()
{
  ifstream readt1;
  readt1.open("test1.yaml");

  while(readt1.good())
  {
    char cc[128];
    readt1.get(cc,128);
    out(cc);
  }
readt1.close();
}

that code… outputs this:

cc: version: 0.14.1
cc: 

with test.yaml being this

version: 0.14.1
name: scrumbleship
author: dirkson
description: >
  A minecraft like game that allows you
  to build your own spaceship!

I’ve tried so many ways to get this to work, and it simply doesn’t

  • 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-04T04:25:47+00:00Added an answer on June 4, 2026 at 4:25 am

    If you add a readt1.ignore(); after the get() it should work:

      while(readt1.good())
      {
        char cc[128];
        readt1.get(cc,128);
        readt1.ignore(); // <--- add this to ignore newline
        out(cc);
      }
    

    This fixes the immediate problem, but using std::getline and std::string would be better C++. Something like:

    while(std::getline(readt1, line)) {// Do stuff}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no clue of where to start on this. I've never done any
I have no clue how to validate this string. I am simply supplying an
I am new to Objective-C and I have no clue why this code is
Anyone have any clue what this error might actually mean? I'm tripping on a
I have no clue as to how to properly write this in raw sql,
I have no clue if this is possible or not as I'm new to
I don't have a clue why this does not work for me. I'm calling
Does anyone have any clue why a code behind function would work in Firefox
I have no clue how i can get an existing object structure based on
I have no clue what an anonymous type is in C# nor how it

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.