Thread: Need Help in Read a file at compilation time to initialize variable

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    2

    Question Need Help in Read a file at compilation time to initialize variable

    I have to read a file (for a string) and the file is available only at the compilation time, not in the run time.

    Is there any possibility to read the file during compilation and initialize a variable with the value read from the file.

    I have tried different methods, but doesn't work for me. Can anybody please tell me how can i do this?


    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    What compiler/IDE do you use?

    Some have pre and post build options that you can use to run a program to do what you need.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    2

    Question

    Quote Originally Posted by Daved View Post
    What compiler/IDE do you use?

    Some have pre and post build options that you can use to run a program to do what you need.
    I'm working on REDHAT LINUX, GNU Compiler.

    What kind of options that i get?

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Are you compiling on the command line? with make? something else?

    You can probably write a program that does a text search in the file and places it in the source code, then run that before the build starts.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. How to read the date & time of a file?
    By megablue in forum C Programming
    Replies: 5
    Last Post: 11-03-2003, 11:58 PM
  4. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM