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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:37:36+00:00 2026-06-06T00:37:36+00:00

Question should say it all. Let’s say there’s a local file mydefaultvalues.txt, separated from

  • 0

Question should say it all.

Let’s say there’s a local file “mydefaultvalues.txt”, separated from the main project. In the main project I want to have something like this:

 char * defaultvalues = " ... "; // here should be the contents of mydefaultvalues.txt

And let the compiler swap " ... " with the actual contents of mydefaultvalues.txt. Can this be done? Is there like a compiler directive or something?

  • 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-06T00:37:37+00:00Added an answer on June 6, 2026 at 12:37 am

    One way to achieve compile-time trickery like this is to write a simple script in some interpreted programming language(e.g. Python, Ruby or Perl will do great) which does a simple search and replace. Then just run the script before compiling.

    Define your own #pramga XYZ directive which the script looks for and replaces it with the code that declares the variable with file contents in a string.

    char * defaultvalues = ...
    

    where … contains the text string read from the given text file. Be sure to compensate for line length, new lines, string formatting characters and other special characters.

    Edit: lvella beat me to it with far superior approach – embrace the tools your environment supplies you. In this case a tool which does string search and replace and feed a file to it.

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

Sidebar

Related Questions

There is group of people [let's say 1874 of them], all representing different companies
Ok, the question of the century :) Before you say or think anything, let
How do I tell cmake where it should output its build data? Let's say
A bit of a generic question but let's say you have a desktop app
Here is one very simple question(or at least at first sight).Let's say we have
I have a question about the architecture of a backbone.js web app. Let's say
Simple (I hope), HTML question. Let's say I have a column group that spans
I have a question on jQuery $(document).ready Let's say we have a HTML page
This is a general question on programming style. Let's say I have an object
Let's say you have a homepage that it's different (but not totally) from the

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.