Mail Archives: djgpp/1998/07/01/09:49:13
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 <stdio.h>
>
#include <string.h> /* 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; */
> }
>
>
>
- Raw text -