ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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..
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..
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?).
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..
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.