Thread: Use a constant in system() ?

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    50

    Use a constant in system() ?

    hi!!

    Lets say i have something like this

    #define dir /home/user


    and somewhere in the program i want to use this defined "dir" with system() function...Is it possible?

    e.g system("dir/folder");

    I think as i remember that this will not work correct..

    Is there any way to make it work like this..?

    Thanks!

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
    #define DIR "/home/user"
    
    ... 
    
    system( DIR "/folder");
    or use sprintf to build whole path from parts into buffer and pass buffer to system
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    50
    Ok thanks a lot my friend for your help and your time

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Syntax error 'constant'
    By SterlingM in forum C++ Programming
    Replies: 6
    Last Post: 10-22-2009, 03:35 AM
  2. constant pointers, a danger?
    By Chris87 in forum C++ Programming
    Replies: 3
    Last Post: 09-30-2008, 01:47 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM