Buna,<br><br>1. De ce faci argv[1] + 1? E suficient argv[1].<br>2. getenv primeste numele variabilei, fara '$': getenv("HOME")<br><br>Mihnea<br><br><div class="gmail_quote">2009/3/28 ana-maria lepar <span dir="ltr"><<a href="mailto:amylepar@gmail.com">amylepar@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Salut,<br><br>Am rulat urmatorul program (banal) :<br><br>==============================<br>
#include <stdlib.h><br>#include <stdio.h><br><br>int main(int argc, char** argv){<br> char * rez ;<br> rez = getenv(argv[1]+1);<br>
printf(" %s \n", rez);<br> return 0;<br>}<br>===============================<br>la rulare :<br>so@elmer:~/teme/tema1_linux/teste_moi$ ./a.out $HOME<br> (null)<br>===============================<br>
nu imi afiseaza deloc variabila de mediu <br>daca rulez in consola echo $HOME imi da rezultatul corect :<br><br>===============================<br>so@elmer:~/teme/tema1_linux/teste_moi$ echo $HOME<br>/home/so<br>===============================<br>
<br>Sistemul de operare : Linux - Debian Etch .<br><br>Poate sa imi explice cineva care este cauza acestui compotament ciudat?<br><br>Multumesc.<br><font color="#888888">Ana<br>
</font><br>_______________________________________________<br>
so mailing list<br>
<a href="mailto:so@cursuri.cs.pub.ro">so@cursuri.cs.pub.ro</a><br>
<a href="http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so" target="_blank">http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so</a><br>
<br></blockquote></div><br>