473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

HOMEDIR, USERNAME, COMPUTER variables...

Are there any variables like %HOMEDIR%, %USERNAME%, etc. that batch
has for C++?

Mar 1 '07 #1
3 1888
On Thu, 01 Mar 2007 04:44:12 -0800, HardHackz wrote:
Are there any variables like %HOMEDIR%, %USERNAME%, etc. that batch
has for C++?
No. That's all system-dependent. C++ doesn't assume that things like
"user" or "directory" even exist (although it does have a notion of
"file"). Think about it: a microchip controlling your fridge might be
programmed in C++...

--
Lionel B
Mar 1 '07 #2
Lionel B wrote:
On Thu, 01 Mar 2007 04:44:12 -0800, HardHackz wrote:
>Are there any variables like %HOMEDIR%, %USERNAME%, etc. that batch
has for C++?

No. That's all system-dependent. C++ doesn't assume that things like
"user" or "directory" even exist (although it does have a notion of
"file"). Think about it: a microchip controlling your fridge might be
programmed in C++...
Not sure what is meant by 'variables like batch has', but if those
are "environment" variables, see 'getenv' function.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Mar 1 '07 #3
Victor Bazarov <v.********@comacast.netwrote:
Lionel B wrote:
>On Thu, 01 Mar 2007 04:44:12 -0800, HardHackz wrote:
>>Are there any variables like %HOMEDIR%, %USERNAME%, etc. that batch
has for C++?

No. That's all system-dependent. C++ doesn't assume that things like
"user" or "directory" even exist (although it does have a notion of
"file"). Think about it: a microchip controlling your fridge might be
programmed in C++...

Not sure what is meant by 'variables like batch has', but if those
are "environment" variables, see 'getenv' function.
Also, your implementation may provide a signature for main() like:

int main(int argc, char* argv[], char* envp[])

where envp is an array of C-style strings representing the current
environment.

See if this works on your implementation:
#include <iostream>

int main(int argc, char* argv[], char* envp[])
{
using std::cout;

for (int i = 0; envp[i] != 0; ++i) {
cout << envp[i] << '\n';
}

return 0;
}

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Mar 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ghazan Haider | last post by:
I am posting this for the lack of a better newsgroup, and for the knowledge of people here, and because its only partially OT. We have a bunch of users with their computers at work. There are...
1
by: ChrisB4745 | last post by:
I'm working on a system service application that is supposed to report various information about the computer it is running on back to a central server. One of the things I need to know is the...
14
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the...
2
by: news.microsoft.com | last post by:
Hello, I want to create a program that will monitor the usage of a particular file and record the date, time, and username of the person who modified the file. The FileSystemWatcher Class...
1
by: kowndinya | last post by:
i want to know the username who is working on a particular computer.(Remote computer) I know already the computer name which is listed in a combo box. Is there any way to get username? please...
3
by: Minkle555 | last post by:
Hi, i am trying to create a program that needs to be logged into before you can access the functions. The user currently has to enter a username and password. However, if they would like change...
8
by: Bruno Barros | last post by:
Hey there. I'm currently working on an intranet, and would like to know how I can get the windows usernames of the visitors. You can get their IP with $_SERVER; But what about their Windows...
0
xxoulmate
by: xxoulmate | last post by:
how to extract username of computer using nbtstat., in dos mode i use nbtstat -a computername then it list down all the workgroup,the computername,and the username was there but the problem., is...
6
xxoulmate
by: xxoulmate | last post by:
how to get the IP address or computer name of a username logged on the network., i got nbtscan which scan ip address on the network and display the username currently log on the computer., what i...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.