How do I concatenate a defines and a string

This is a discussion on How do I concatenate a defines and a string within the C Programming forums, part of the General Programming Boards category; Code: #define CONFIG_PATH "/etc/openvpn/conf" glob_t gl; glob("/etc/openvpn/conf/*.conf", 0, NULL, &gl); Consider the above. I want to utilize the CONFIG_PATH defines ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    2

    How do I concatenate a defines and a string

    Code:
    #define CONFIG_PATH "/etc/openvpn/conf"
    
    glob_t gl;
    
    glob("/etc/openvpn/conf/*.conf", 0, NULL, &gl);
    Consider the above. I want to utilize the CONFIG_PATH defines in the glob statement.
    How can I do this economically and without reducing performance?

    Thanks.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    What, you mean this?
    Code:
    glob(CONFIG_PATH "/*.conf", 0, NULL, &gl);

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    2
    I didn't know you could concat strings like that in C.

    Thanks for that.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    That only works for string literals.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21