www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/01/09:49:13

Date: Wed, 1 Jul 1998 08:49:57 -0500 (CDT)
From: Andrew Deren <aderen AT eecs DOT uic DOT edu>
To: Fozzy the Bear <fozzy99 AT geocities DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Simple password program
In-Reply-To: <3599C945.3AC1F40B@geocities.com>
Message-ID: <Pine.GSO.3.96.980701084557.16617A-100000@bert.eecs.uic.edu>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019