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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:32:22+00:00 2026-05-10T20:32:22+00:00

In cmd.exe, I can execute the command copy c:\hello.txt c:\hello2.txt and it worked fine.

  • 0

In cmd.exe, I can execute the command ‘copy c:\hello.txt c:\hello2.txt’ and it worked fine. But in my C program, I ran this piece of code and got the following error:

#include <iostream>  using namespace std;  int main() {     system('copy c:\hello.txt c:\hello2.txt');     system('pause');      return 0; } 

Output: The system cannot find the file specified.

Anybody know what is going on here?

  • 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. 2026-05-10T20:32:23+00:00Added an answer on May 10, 2026 at 8:32 pm

    Inside C strings (and quite a few other languages that use the same escaping rules), \ should be \\ since it’s the escape character. It allows you to enter, in normal text, non-printable characters such as:

    • the tab character \t.
    • the carriage-return character \r.
    • the newline character \n.
    • others which I won’t cover in detail.

    Since \ is used as the escape character, we need a way to put an actual '\' into a string. This is done with the sequence \\.

    Your line should therefore be:

    system('copy c:\\hello.txt c:\\hello2.txt'); 

    This can sometimes lead to obscure errors with commands like:

    FILE *fh = fopen ('c:\text.dat', 'w'); 

    where the \t is actually the tab character and the file that you’re trying to open is:

                c:TABext.dat.

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

Sidebar

Related Questions

I am running into this problem. my program invokes Runtime.getRuntime().exec(cmd); on a windows platform.
This is a VBScript code example that shows how to catch whatever a command
Source:http://jpsoft.com/help/index.htm?alias.htm Aliases can use command line parameters or parameters like those in batch files.
the problem in a nutshell: running plink(with specific arguments) works from cmd, but not
I'm trying to create a cmd file that will install a .msi and then
Is it possible to open the command prompt (and I guess any other terminal
I have a batch file that executes three Maven commands, one after the other.
I'm trying to get Powershell to run my PS script in post built -
I'm learning Windows kernel mode driver development. I've written a small test driver that
I am writting a build script with Powershell. The scripts performs various operations such

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.