Use a constant in system() ?

This is a discussion on Use a constant in system() ? within the C Programming forums, part of the General Programming Boards category; hi!! Lets say i have something like this #define dir /home/user and somewhere in the program i want to use ...

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

    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Code:
    #define DIR "/home/user"
    
    ... 
    
    system( DIR "/folder");
    or use sprintf to build whole path from parts into buffer and pass buffer to system
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    34
    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, 04:35 AM
  2. constant pointers, a danger?
    By Chris87 in forum C++ Programming
    Replies: 3
    Last Post: 09-30-2008, 02:47 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03: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

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