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

  • Home
  • SEARCH
  • 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 120737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:51:31+00:00 2026-05-11T03:51:31+00:00

I want to create a file using C++, but I have no idea how

  • 0

I want to create a file using C++, but I have no idea how to do it. For example I want to create a text file named Hello.txt.

Can anyone help me?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T03:51:32+00:00Added an answer on May 11, 2026 at 3:51 am

    One way to do this is to create an instance of the ofstream class, and use it to write to your file. Here’s a link to a website that has some example code, and some more information about the standard tools available with most implementations of C++:

    ofstream reference

    For completeness, here’s some example code:

    // using ofstream constructors. #include <iostream> #include <fstream>    std::ofstream outfile ('test.txt');  outfile << 'my text here!' << std::endl;  outfile.close(); 

    You want to use std::endl to end your lines. An alternative is using ‘\n’ character. These two things are different, std::endl flushes the buffer and writes your output immediately while ‘\n’ allows the outfile to put all of your output into a buffer and maybe write it later.

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

Sidebar

Related Questions

How can I create a .txt file using flex 3? And I want to
I want to create war using grails, but by default it creates war file
This the model that I want to create using json file Ext.define('Users', { extend:
I'm able to create an excel file using apache poi. however, i want users
Using C# and WinForms in VS2008, I want to create a file browser control
I am using phpexcel to create a xls file. I want to turn off
I want to write program using C in Visual studio 2008. But I have
I want to create a Text file in my code behind file in my
I want to create a chat room using HTML5 web sockets, but am pretty
I've created an ics file using DDay iCal library. Now I want to make

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.