How to start program from subfolder

This is a discussion on How to start program from subfolder within the C Programming forums, part of the General Programming Boards category; HI OS Linux, C programming I have one folder itTestMenu in which are folders with programs. In program folders are ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    23

    How to start program from subfolder

    HI
    OS Linux, C programming
    I have one folder itTestMenu in which are folders with programs. In program folders are executable files like a.out and similar. So main folder is a menu in which are subfolders where are programs that you choose from menu are located. I would just like to ask you how to write path of those programs that would just check subfolder of that name and executable file - that I wouldn't write path from whole system. If I transfer program(menu folder) to other location paths wont be right and programs from menu won't start, so I would like that no matter where the location of menu folder is it always checks the subfolder with that name and executable file ,so you can move folder and programs always start. Please help.
    Have a nice Day

    Matt

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,171
    You can use setenv() to change the PATH shell variable. It only effects it for the running program, so when your menu program exits, the shell will still be using your old, unmodified PATH variable.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    You can use opendir()+readdir()+closedir()+stat() (POSIX functions) to figure out which files in a directory are directories. (And maybe chdir(), too.)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Start program games
    By Livijn in forum C++ Programming
    Replies: 11
    Last Post: 04-18-2007, 12:01 PM
  2. how to make my program run on windows start up
    By kantze in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 03-24-2007, 12:14 PM
  3. Start up program
    By Breetai in forum Windows Programming
    Replies: 2
    Last Post: 01-11-2003, 01:12 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. Start a program
    By FunkeeMunkee in forum C++ Programming
    Replies: 1
    Last Post: 08-26-2001, 08:18 PM

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