Date: Wed, 1 Jul 1998 08:49:57 -0500 (CDT) From: Andrew Deren To: Fozzy the Bear cc: djgpp AT delorie DOT com Subject: Re: Simple password program In-Reply-To: <3599C945.3AC1F40B@geocities.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Tue, 30 Jun 1998, Fozzy the Bear wrote: > Hello I am new to C but have learned alot so far, I tried to make a > simple password program, but it didn't turn out to be so simple. I > can't get it to work. I get this error: > password.c: In function `main': > password.c:22: invalid lvalue in assignment > please help me figure out what is wrong. > > ---------------------------start > here------------------------------------ > I don't know which line is 22 but I can fix some things for you: > #include > #include /* look later at strcmp */ > main() > { > char name[30],password[50]; /* enough ?? */ > > printf("login: "); > scanf("%s",name); > printf("password: "); > scanf("%s",password); > > if(&name="fozzy") /* ,&password==bear */ This is probably your error line, you are trying to assign "fozzy" to an address of a pointer. /* to compare strings use strcmp(string1, string2) it returns 0 if they are euqal */ if(strcmp(name, "fozzy")==0) > { > printf("Welcome %s\n"); /* you specified a string to be printed but did not pass it */ printf("Welcome %s\n", name); > } > else > { > print("You Do Not Have authorisation To Use This Computer!"); > print("This Attempt Will Be Logged When I Learn How"); > } > > /* return 0; */ > } > > >