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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:49:01+00:00 2026-06-04T11:49:01+00:00

Possible Duplicate: Creating a directory In C or C++ I want to make a

  • 0

Possible Duplicate:
Creating a directory In C or C++

I want to make a folder that is titled “BobtheBuilder”. And then I want to create a text file inside of it. I want to do this without being aware of my path. I don’t want to have to type in:

ofstream out("C:/MyComputer/User/Jeff/etc/BobtheBuilder/NewFile.txt");

I want it just to be local to this area where my executable is contained like this:

ofstream out("/BobtheBuilder/NewFile.txt");

is this possible? Do I have to know the whole path name in order to do file management? I feel like this is possible because you can create or open a file that is in the same directory as the program like:

ifstream inf("NewFile.txt");

Or is there a special keyword that fills in the previous path like this:

ifstream inf("FILLIN/BobtheBuilder/NewFile.txt");

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-04T11:49:02+00:00Added an answer on June 4, 2026 at 11:49 am

    You can absolutely specify a relative path like “BobtheBuilder/NewFile.txt” without specifying the whole path.
    You would however need to create the folder first before the file.
    Since creating folders is platform specific and since you’re on Windows, you would need to call the CreateDirectory function with “BobtheBuilder” as its parameter.
    The folder would then be created in the default working directory of the program which is the same folder where the executable resides.
    You can change this working directory using the SetCurrentDirectory function before creating the folder and file.

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

Sidebar

Related Questions

Possible Duplicate: Load local HTML file in a C# WebBrowser I´m creating program in
Possible Duplicate: How do I create a directory and parent directories in one Perl
Possible Duplicate: How to open-source an application that uses API keys I'm creating an
Possible Duplicate: How can I create a multilingual android application? I am creating application
Possible Duplicate: “new” keyword in Scala Ive noticed that creating certain instances in Scala
Possible Duplicate: Creating makefile Hello, I am trying to create the makefiles and configure
Possible Duplicate: Creating constant in Python Does Python support constants that are enforced by
Possible Duplicate: Creating, opening and printing a word file from C++ Hi, I need
Possible Duplicate: How to create xhtml elements with javascript Creating a <br /> with
Possible Duplicate: Prevent Direct Access To File Called By ajax Function I'm creating a

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.