LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 05-26-2008, 11:43 PM   #1
babag
Member
 
Registered: Aug 2003
Posts: 419

Rep: Reputation: 31
c++ - path question


is there a way to return the current a account in c++?
i'm thinking of how to return something like "/home/babag."

i have a small app that i need to run on more than one box.
once in the account, the paths will be pretty much the
same on each. i'm thinking that if i can return the account
home path, i can store it in one variable and store the
rest of the path in another and put the two together to
form the path for the current box.

for example, each box might be in variable1, while a common
part of the path might be in variable2.

variable1 = /home/_this_account;
variable2 = "/path_to_app";

thanks,
BabaG
 
Old 05-27-2008, 03:27 AM   #2
clvic
Member
 
Registered: Feb 2008
Location: Rome, Italy
Distribution: OpenSuSE 11.x, vectorlinux, slax, Sabayon
Posts: 206
Blog Entries: 2

Rep: Reputation: 45
Depending on your system, you can make use of the getenv function (look at the manpage to know what standards define it, anyway it is POSIX).
The name of the variable you're looking for is HOME, you can also look at it from bash by typing "echo $HOME", the C function should return you the same string as in bash.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
PATH question radiodee1 Debian 12 03-16-2007 10:06 AM
A question about $PATH...... grim1234 Slackware 2 11-04-2005 01:00 PM
PATH question satimis Linux From Scratch 5 09-15-2005 10:23 AM
question about $PATH drewski Linux - General 2 01-06-2004 02:17 AM
Question on path PatC Linux - General 1 07-09-2002 09:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:56 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration