473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

error: incompatible types in asignment

Hi all,

the following programm is supposed to check for login and password
with inbuilt linux functions. in line 57 and 64 there are erorrs:
incompatible types in asignment. whats wrong with this? the crypt
function returns a pointer to a char. why an assignment to a char
vector is not possible?

MfG Dennis


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _XOPEN_SOURCE
#include <assert.h>
#include "auth.h"
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <shadow.h>
#include <unistd.h>

int main() {

struct passwd *pw;
struct spwd *spw;

char temp[4];
char user[20];
char pass[20];
char encryptedinput[20];
char encryptedpw[30];
char salta[12];
char saltb[2];

printf("%s", "User: ");
scanf("%s", &user);
printf("\n\n");
printf("%s", "Passwort: ");
scanf("%s", &pass);
printf("\n\n");
// prueft ob user vorhanden
if( ( pw = getpwnam( user ) ) == NULL ) {
fprintf( stderr, "getpwnam: unknown %s\n",user );
exit( EXIT_FAILURE );
}
// pruefe ob superuser
if (strcmp(pw->pw_passwd, "x") == 0) {
if( ( spw = getspnam( user ) ) == NULL ) {
fprintf( stderr, "getspnam: unknown %s\n",user );
exit( EXIT_FAILURE );
}
strcpy(encryptedpw,spw->sp_pwdp);
// wenn kein superuser
} else {
strcpy(encryptedpw,pw->pw_passwd);
}
// hole erste drei zeichen
strncpy(temp,encryptedpw,3);
temp[3]='\0';
if ((strcmp(temp,"$1$"))==0) {
strncpy(salta,encryptedpw,12);
salta[12]='\0';
if( ( encryptedinput = crypt( pass, salta ) ) == NULL ) {
fprintf( stderr, "Fehler beim verschluesseln");
exit( EXIT_FAILURE );
}
} else {
strncpy(saltb,encryptedpw,2);
saltb[2]='\0';
if( ( encryptedinput = crypt( pass, saltb ) ) == NULL ) {
fprintf( stderr, "Fehler beim verschluesseln");
exit( EXIT_FAILURE );
}
}
// verschluessle passwort

if (strcmp(encryptedinput, encryptedpw) == 0) {
printf("%s\n\n","LOGIN ERFOLGREICH!!!");
} else {
printf("%s\n\n","LOGIN FEHLGESCHLAGEN!!!");
}
exit( EXIT_SUCCESS );
}
Nov 14 '05 #1
2 2163
Dennis Schulz wrote:
Hi all,

the following programm is supposed to check for login and password
with inbuilt linux functions. in line 57 and 64 there are erorrs:
incompatible types in asignment. whats wrong with this? the crypt
function returns a pointer to a char. why an assignment to a char
vector is not possible?
Arrays are not assignable in C.
char encryptedinput[20];
This should probably be `char *encryptedinput;'.
[...]
if( ( encryptedinput = crypt( pass, salta ) ) == NULL ) {


If you do not understand the difference between an array
and a pointer, please see Question 6.8 -- in fact, all of
Section 6 -- in the comp.lang.c Frequently Asked Questions
(FAQ) list at

http://www.eskimo.com/~scs/C-faq/top.html

--
Er*********@sun.com

Nov 14 '05 #2
In 'comp.lang.c', d.********@gmx.net (Dennis Schulz) wrote:
scanf("%s", &user);


Crackers heaven!

--
-ed- get my email here: http://marreduspam.com/ad672570
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: user | last post by:
Hi, I got this error and donno know how to fix it: In file included from ../except.h:53, from group.c:22: .../portspecs.h:81: error: conflicting types for `const double __infinity'...
0
by: Jan | last post by:
While building PHP 4.4.0 on a fresh installed FreeBSD 5.4 I get the following error: www# /bin/sh /usr/home/c/console/toolscon/web/2/php-4.4.0/libtool --silent --preserve-dup-deps...
7
by: Brian Stubblefield | last post by:
Dear clc members, I am new to C and am posting several messages concerning a large C program that I am debugging. I am encountering a "incompatible types in assignment" warning for the...
8
by: fei.liu | last post by:
I have the following source code. It seems wierd to me why gca's value cannot be reassigned. It's afterall a pointer and has a pointer value. I am aware that the standard says it's not allowed. But...
4
by: pandaemonium | last post by:
I have two quick problems with the code I am writing: First, I define a struct of char arrays (strings) and then try accessing the same. I get an "incompatible types in assignment" error: struct...
2
by: kardon33 | last post by:
I am getting a "error: incompatible types in assignment" error and cant figure out why? I am trying to set lastRow to row at the end of the code snippet. int row; int lastRow; size_t...
1
by: Benga89 | last post by:
Hi! I'm currently working on a small program that prints records of a database. However during compilation I'm getting an error: "Incompatible types in assignment". I'm al ittle bit stuck...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.