LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 11-13-2007, 01:55 AM   #1
peedaro
LQ Newbie
 
Registered: Oct 2007
Posts: 19

Rep: Reputation: 0
create directory.??


i have saved a program written in c in the home directory..
now i want to shift this program into a new directory within the home directory..with the the original copy of the prog in the home directory..
i want to execute this prog from the sub-directory..
is the command cc prog.c sufficent..??the reason why i want to
shift the prog in sub-directory is that the data type mode_t is not getting recognised inspite of including the header files
<sys/stat.h>
<sys/types.h>
<unistd.h>
<fcntl.h>
please help..
 
Old 11-13-2007, 07:09 AM   #2
noranthon
Member
 
Registered: Apr 2006
Location: Australia
Distribution: PCLinuxOS with Xfce
Posts: 299

Rep: Reputation: 30
You have to either include the host directory in your PATH or include the path in the command you use. Is that what you mean?
 
Old 11-14-2007, 09:33 AM   #3
peedaro
LQ Newbie
 
Registered: Oct 2007
Posts: 19

Original Poster
Rep: Reputation: 0
The code which i have built has to be implemented only in the sub directory...The root directory shouldn be considered...
the code is right...but it is working with respect to the root directory...i want to implement this code in the sub directory....and not to the root directory..
 
Old 11-14-2007, 10:55 PM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 10.04, Crunchbang Statler
Posts: 3,325

Rep: Reputation: 168Reputation: 168
I do not 100% understand the question.

Can you explain when you get the problem that 'mode_t is not recognized'? Is that when you compile your program in your subdirectory? Or is that when you run the program (in which case I don't understand the problem at all)?

You should be able to compile a program in any directory that you have write access to; there should not be a difference between compiling in your home directory or compiling in a subdirectory of your home directory (unless you use relative paths).
Next you should also be able to move the program to any directory that you have write access to and run it from there.
  • How do you compile?
  • If it's a short program, can you show us the code? Else at least the part where you include the mentioned files?
Although it should not be relevant, please post the distro as well (or is it for a non-linux OS?).
 
Old 11-15-2007, 11:28 AM   #5
peedaro
LQ Newbie
 
Registered: Oct 2007
Posts: 19

Original Poster
Rep: Reputation: 0
mode_t is the datatype present in <sys/stat.h>...just like time_t is present in time.h....the latter is considered as a datatype but mode_t is not getting recognised either in the function or the main()...so i thought the problem occured because it was executed in the main directory as mode_t could change permissions. for files created..
 
Old 11-15-2007, 10:11 PM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 10.04, Crunchbang Statler
Posts: 3,325

Rep: Reputation: 168Reputation: 168
mode_t should only give you grey hairs during compile. This can happen if you use relative paths for in your source code and move the source to a subdirectory in which case the relative path will point to the wrong directory. It can also happen if the compiler looks in the wrong directory for the include files.
However, in that case the compiler should complain that it can't find the file, not that mode_t is unknown.

If you need more help, pleae post the EXACT error/warning that you get.
 
Old 11-16-2007, 09:22 AM   #7
peedaro
LQ Newbie
 
Registered: Oct 2007
Posts: 19

Original Poster
Rep: Reputation: 0
ok..i ll try givin the permissions as the argument and declare mode_t globally...hopefully it should work..
 
Old 11-18-2007, 11:24 AM   #8
iwasapenguin
Member
 
Registered: Jul 2007
Posts: 110

Rep: Reputation: 15
I think the question is how to add your home directory into your path (list of directories that you can run programs from peedaro).
Can somebody post the required adjustments to a .profile file? I never could be bothered put it to memory.
 
Old 11-18-2007, 10:14 PM   #9
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 10.04, Crunchbang Statler
Posts: 3,325

Rep: Reputation: 168Reputation: 168
I don't think that that's the question; mode_t is something related to source code, not to executables.

But OK, on my Slackware12 box, the following is in /etc/profile


Code:
# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi
The above code adds some directories to the PATH for root and the code below adds the current directory to the path.
Code:
# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
  PATH="$PATH:."
fi
 
Old 11-20-2007, 01:24 AM   #10
peedaro
LQ Newbie
 
Registered: Oct 2007
Posts: 19

Original Poster
Rep: Reputation: 0
thank you...i shall apply it in the code...thanks again..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create a directory in C++ poeta_boy Programming 15 11-02-2011 01:53 PM
How do i create a directory ? vskgopu Programming 1 07-26-2006 03:25 AM
can't create new directory dummoi Linux - Newbie 4 06-24-2004 02:50 PM
Can't create new directory!!?? catty Linux - Newbie 7 10-06-2003 05:33 PM
Create a directory SnowSurfAir Linux - Software 15 07-21-2003 06:12 PM


All times are GMT -5. The time now is 08:48 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration