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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:35:01+00:00 2026-05-26T23:35:01+00:00

The compiler doesn’t complain while building,and my program says it worked, and creates the

  • 0

The compiler doesn’t complain while building,and my program says it worked, and creates the folder, but the file hasn’t moved. What am I doing wrong?

#include <iostream>
#include <boost/filesystem.hpp>

using namespace std;
using namespace boost::filesystem;

char c = 'c';

bool move(){

 if ((bool) rename("C:\\fldr1" "rawr.txt", "C:\\fldr2" "rared.txt") == (true)){
    return true;
 }
 else{
    return false;
 }

}
int main(int argc, char argv[])
{

    if (argv[1] = (c))
    {
        if (is_directory("C:\\fldr2")){

            if (move){
            cout << "Done 1!" << endl;
            }
        }
        else{
            cout << "Dir doesn't exist!" << endl;

            if ((bool)create_directory("C:\\fldr2") == (true)){

                if (move){
                    cout << "Done 2!" << endl;
                }
            }
        }
    }
    return 0;
}

I’m using Windows 7, CodeBlocks 10.05, G++ 4.4.1, and Boost 1.47

  • 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-26T23:35:01+00:00Added an answer on May 26, 2026 at 11:35 pm
    • Avoiding c-style casts helps in avoiding many problems like accidentally doing if(void)
    • implicit concatenation of strings "C:\\fldr1" "rawr.txt" == "C:\\fldr1rawr.txt" also may produce undesired results.
    • Boost rename can throw exceptions which you aren’t handling either.
    • Relying on implicit casting of literal string to boost path is a lesser problem.

    You could do something like the following instead:

    bool move()
    {
      path src("C:\\fldr1\\rawr.txt");
      path dest("C:\\fldr2\\rared.txt");
    
      try {
        rename(src, dest);
      }
      catch (...)
      {
        return false;
      }
    
      return exists(dest);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be iPhone specific, I'm not sure. The compiler doesn't complain when building
The compiler doesn't seem to mind it so far but I just wanted to
I want create object from Canvas3D class(in java) but my Compiler doesn't have this
I would like to do the following, but the compiler doesn't like it: unsigned
The compiler doesn't know where stat.h is? Error: c:\Projects\ADC_HCI\mongoose.c(745) : error C2079: 'st' uses
It looks like the run-time compiler doesn't support the same language as the command-line
This doesn't seem to work (compiler complains that Something 's getFoo() method doesn't implement
C# doesn't require you to specify a generic type parameter if the compiler can
I have the following code, which compiles but doesn't bring back any data. Here
If a compiler doesn't support RTTI, does that mean that the compiler can not

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.