A question on C programming and Outputing variables


 
Thread Tools Search this Thread
Top Forums Programming A question on C programming and Outputing variables
# 1  
Old 12-05-2003
Error A question on C programming and Outputing variables

I was wondering if someone could show me what I'd need to do in C programming language to output the current values of all of your environment variables and do so in such a way that it will duplicate an "env" command on unix. Does anyone know how and can you share it with me?

Thanks in advance.
# 2  
Old 12-05-2003
you have the getenv function

or you can have your main as

int main(argc, argv, env)
int argc;
char *argv[];
char *env[];
{
int cnt;
for(cnt=0;env[cnt];cnt++)
printf("%s\n",env[cnt]);
return 0;
}
# 3  
Old 12-05-2003
Thanks

My gratitude to you. ^___^
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

More a logic than a programming question

hello, I'm a littlebit lost... i have a table of single names and combination of two names and i want a table of ALL single names with ALL combinations (also the indirect ones). - - - in reality the names are longer, not only a,b,.. and the table is tab-delimited, and the result table... (6 Replies)
Discussion started by: dietmar13
6 Replies

2. UNIX for Dummies Questions & Answers

General Programming Question

Experience level : New to programming in Linux. Forgive my noobiness in this context with regards to programming, language or grammar. Some Background info : I have seen a lot of programs which I use (Modo and Maya especially) which can use a command line to run the different parts of the... (2 Replies)
Discussion started by: snd321
2 Replies

3. UNIX for Dummies Questions & Answers

Programming question

How do I create a program that will allow a user to type in a number, while the program outputs that number in words. For example, if a user types in 21, the computer would respond with twenty-one. Please allow the program to work for 0-30. How do I let the user know if a number typed in is not in... (2 Replies)
Discussion started by: lexydoll87
2 Replies

4. Shell Programming and Scripting

outputing sed to a variable

Hello, My appologies for asking a very basic question but... In a shell, I enter: echo tit | sed -e s/tit/tat/g This returns: tat as expected. But when I enter: set test = `echo tit | sed -e s/tit/tat/g` echo $test This returns an empty line. Why is this so and how... (3 Replies)
Discussion started by: flewis
3 Replies

5. Programming

C programming question

How do I find multiples of a number in C programming? Thanks (4 Replies)
Discussion started by: Aseda
4 Replies

6. Shell Programming and Scripting

question about about Shell programming

1.if 2.then 3. # save the number of args and first argument in variables. 4. num_args=$# 5. id="$1" 6. echo "$id" 7. #echo "$1" > crapfile.txt 8. echo `sed 's/\*/'\*'/g' < crapfile.txt` Above is a partial code.I would like to ask: at line 1:... (1 Reply)
Discussion started by: thungmail
1 Replies

7. UNIX for Dummies Questions & Answers

programming question... sorta

i didnt wanna post this in C/C++ or Shell programming, because its neither... closest would be Shell... but anywayz, what would (in your opinion) be the easiest route in creating shell gui's?.... im not talking about XFree86 objects, but rather... like the shell setup screen, the cheezy blue popup... (2 Replies)
Discussion started by: 01000101
2 Replies

8. Programming

programming question from a newbie, please help

Hi Everyone, I really hope I could get some insight from a few of you, I've been searching the net for various resources, and this board seems to be the friendliest and most helpful by far. I work for a medical research company and we use sun 4 and we have different studies that have their... (1 Reply)
Discussion started by: milenky
1 Replies

9. Shell Programming and Scripting

Question about Shell Programming

First, I'd like to know if being a shell programmer considered a "real" programmer. is it?? also, I do create a lot of shell programs which includes full scripts to create users and maintaining records. ie phone records. now, I hear the programmer has to do some cleaning up after the... (3 Replies)
Discussion started by: IMPORTANT
3 Replies
Login or Register to Ask a Question