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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:50:55+00:00 2026-05-23T07:50:55+00:00

My programs have been running properly for over a year. Today I copied the

  • 0

My programs have been running properly for over a year. Today I copied the files onto a different system and compiled every program.

When I compile and run from Dev-c++ it writes data onto a text file like its supposed to, but when I click on the executable it creates, it does not write data onto the file. Everything else like input/output seems to work.

What procedure have I missed?

Ok i’ve given the program Full permision but it still does not write.

I’m quite puzzled, atleast if it didn’t run when i compile it in the C++ environment i can keep checking my code, but only the .exe does not work, any other suggestions ?

 #include <iostream> 
 #include <fstream>
 using namespace std; 
 int main() {  
 ofstream bss2; 
 bss2.open("expat.txt",ios::app);
 bss2 << 2 ; 
 bss2.close();
 } 

This is the sample code i tested out.

How do i find the Current working directory ?

Ok i changed a line to

bss2.open("c:\\expat2.txt",ios::app);

and now it works properly in the exe file.

but there’s over 50 files and i prefer i didn’t have to spell out the new path to each one, what workaround is there to set the directory to the one previously used ?

update 4 :

 #define _POSIX_SOURCE
 #include <unistd.h>
 #undef _POSIX_SOURCE
 #include <stdio.h>

 main() {
   char cwd[256];
   int y;
   if (chdir("/tmp") != 0)
     perror("chdir() error()");
   else {
     if (getcwd(cwd, sizeof(cwd)) == NULL)
       perror("getcwd() error");
     else
       printf("current working directory is: %s\n", cwd);
   }
   scanf(y);
 }

Ok i used the getcwd() and this is the message it gives me

chdir() error(): No such file or directory

How do i set the directory now.

  • 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-05-23T07:50:56+00:00Added an answer on May 23, 2026 at 7:50 am

    The best and easiest way is to give the full path of the output file rather than just the filename. That way, you can be sure where the file went, and not have to search for it everywhere. If you are using Windows, the output file might be somewhere in system32. But I could be wrong.

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

Sidebar

Related Questions

I have recently been put in charge of debugging two different programs which will
I have suddenly been getting the memory exception errors for two programs running on
I have been trying to create a Ruby program that will be running online
I have been trying some programs in the C Language and come across to
I understand object oriented programming, and have been writing OO programs for a long
I have been tasked with creating a program what will create take files in
For about a year I have been thinking about writing a program that writes
I have recently developed a habit of running all of my programs through valgrind
So far I have been writing programs in Java. So when I started C++,
We have two machines (under discussion) running ClearCase - different versions of ClearCase. Otherwise,

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.