Date: Wed, 1 Jul 1998 09:55:01 +0200 (MET DST) From: Federico Spinazzi 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: > if(&name="fozzy") /* ,&password==bear */ The problem should be here. The = operator is for assignement, like := in pascal; the equivalence operator is == : if ( A == B) but, you are assigning, while trying to test for equivalence, an array of char to the address of name ! I think there are at least 4 ploblems: 1 - = instead of ==; 2 - the use of "foozy": you should have declared char Foozy[] = "foozy"; and then used Foozy, but see 3; I think that declaration is the only point were you can use a literal string i.e.: you can use it only during a declaration/inizialization; I've expressed this point very badly because you can always write things like fprintf(stdout, "foozy") or strcmp(name, "foozy"); 3 - you think to be able to compare two 'strings' by means of ==, don't you ?: you can't, you have to use , e.g., the library function strcmp and its similar: if (strcmp(name, "foozy") == 0) /*then they are the same sequence of chars */ 4 - the & operator here returns the memory address of a variable, so, how can you compare it with a 'string' (apple with elefants)? 5 - there should be a libc function that break the echo on the screen while writting input from keyboard: it could be useful while reading passwords. I don't remember its name. I provide here a maybe useful link for better help. DJGPP mailing list is not direcly related to C problems, even if I also have posted question like that here (people here is so kind :-)): C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html hope that help, federico