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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:33:38+00:00 2026-05-24T00:33:38+00:00

It looks like this question is pretty simple but I can’t find the clear

  • 0

It looks like this question is pretty simple but I can’t find the clear solution for copying files in C without platform dependency.

I used a system() call in my open source project for creating a directory, copying files and run external programs. It works very well in Mac OS X and other Unix-ish systems, but it fails on Windows. The problem was:

system( "cp a.txt destination/b.txt" );
  • Windows uses backslashes for path separator. (vs slashes in Unix-ish)
  • Windows uses ‘copy’ for the internal copy command. (vs cp in Unix-ish)

How can I write a copying code without dependency?

( Actually, I wrote macros to solve this problems, but it’s not cool. http://code.google.com/p/npk/source/browse/trunk/npk/cli/tests/testutil.h, L22-56 )

  • 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-24T00:33:40+00:00Added an answer on May 24, 2026 at 12:33 am

    You need to use the C standard library functions in stdio.h.

    In particular, fopen, fread, fwrite, and fclose will be sufficient.

    Be sure to include the b (“binary”) option in the flags to fopen.

    [edit]

    Unfortunately, the file names themselves (forward-slashes vs. back-slashes) are still platform dependent. So you will need some sort of #ifdef or similar to deal with that.

    Or you can use a cross-platform toolkit.

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

Sidebar

Related Questions

Looks like this question has been asked thousand times already, but each person's configuration
It looks like this question has been asked dozens of times, but none of
Problem: I have a string that looks like this: [1=>2,3,4][5=>6,7,8][9=>10,11,12][13=>14,15][16=>17,18] Question: How can you
All, I'm sure this is a pretty simple SQL query question, but I'm sure
This is a pretty frustrating newb question, but I can't seem to get iteration
Apologies if this is a simple question, I'm still pretty new to this, but
Absolute beginner question: I have a template file index.html that looks like this: ...
Quick question... I have a query that checks for duplicates that looks like this:
Noob question here! I have an array with hashes that looks like this: arr
Okay guess this question looks a lot like: What is the best way to

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.