[so] [Linux] Comportament ciudat variabile de mediu

Mihnea Muraru mmihnea at gmail.com
Sat Mar 28 22:50:14 EET 2009


Buna,

1. De ce faci argv[1] + 1? E suficient argv[1].
2. getenv primeste numele variabilei, fara '$': getenv("HOME")

Mihnea

2009/3/28 ana-maria lepar <amylepar at gmail.com>

> Salut,
>
> Am rulat urmatorul program (banal) :
>
> ==============================
> #include <stdlib.h>
> #include <stdio.h>
>
> int main(int argc, char** argv){
>         char * rez ;
>         rez = getenv(argv[1]+1);
>         printf(" %s \n", rez);
>         return 0;
> }
> ===============================
> la rulare :
> so at elmer:~/teme/tema1_linux/teste_moi$ ./a.out $HOME
>  (null)
> ===============================
> nu imi afiseaza deloc variabila de mediu
> daca rulez in consola echo $HOME imi da rezultatul corect :
>
> ===============================
> so at elmer:~/teme/tema1_linux/teste_moi$ echo $HOME
> /home/so
> ===============================
>
> Sistemul de operare : Linux  - Debian Etch .
>
> Poate sa imi explice cineva care este cauza acestui compotament ciudat?
>
> Multumesc.
> Ana
>
> _______________________________________________
> so mailing list
> so at cursuri.cs.pub.ro
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cursuri.cs.pub.ro/pipermail/so/attachments/20090328/c7e462fe/attachment.htm>


More information about the so mailing list