Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > why this code does not compile?

Reply
Thread Tools

why this code does not compile?

 
 
Simon Biber
Guest
Posts: n/a
 
      08-21-2003
"CBFalconer" <(E-Mail Removed)> wrote:
> Ninan Thomas wrote:
> >
> > #define MAX_PATH_NAME 100
> >
> > char audithome[MAX_PATH_NAME];
> >
> > audithome = getenv("AUDITHOME");

> ^^^^^^^^^ ^---------see below for what this returns.
> this is not an lvalue.


It is an lvalue. It is not a modifiable lvalue.

C99 6.3.2.1 Lvalues, arrays, and function designators
1 An lvalue is an expression with an object type or an
incomplete type other than void;53) if an lvalue does
not designate an object when it is evaluated, the
behavior is undefined. When an object is said to have
a particular type, the type is specified by the lvalue
used to designate the object. A modifiable lvalue is
an lvalue that does not have array type, does not have
an incomplete type, does not have a const-qualified
type, and if it is a structure or union, does not have
any member (including, recursively, any member or
element of all contained aggregates or unions) with a
const-qualified type.

--
Simon.


 
Reply With Quote
 
 
 
 
Ninan Thomas
Guest
Posts: n/a
 
      08-21-2003
Hi all
Thanks for all the replies to this question. I have a follow up question.

I agree
char *audithome = getenv("AUDITHOME");
works.

My question is if i define

char audithome[MAX_PATH_NAME];

and pass it as an argument to any function for example
strcpy (char *, ------

strcpy(audithome,
it works. Here the argument is a pointer to char type???
where as it does not work when the function returns a char * type?

for example char *getenv(-------


audithome = getenv("AUDITHOME")
http://www.velocityreviews.com/forums/(E-Mail Removed) (Ninan Thomas) wrote in message news:<(E-Mail Removed). com>...
> #define MAX_PATH_NAME 100
>
>
> char audithome[MAX_PATH_NAME];
>
> audithome = getenv("AUDITHOME");
>
>
>
> this fails to compile giving an error
> "incompatible types in assignment"
>
> I am using gcc compiler on Solaris
>
> REgards
>
> Ninan

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why :: ? Why not : ? Why not . ? <- less clutter ?!? Skybuck Flying C++ 16 08-25-2007 09:48 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why why why does function not work Horace Nunley ASP .Net 1 09-27-2006 09:52 PM
Why does this (very simple piece of) code does not work? jblazi Python 5 08-16-2004 01:30 PM



Advertisments