Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "listas.h"
no *username(no *ptr);
int password(no *ptr);
int main(void) {
no *fst = NULL;
no *user1 = malloc(sizeof (no));
user1->prox = NULL;
user1->user = malloc(sizeof (user));
user1->user->numec = 8080163;
user1->user->pass = "password";
user1->user->nome = "Fabio Teixeira";
user1->user->tipouser = 3;
fst = user1;
no *user2 = malloc(sizeof (no));
user2->prox = NULL;
user2->user = malloc(sizeof (user));
user2->user->numec = 8010672;
user2->user->pass = "password";
user2->user->nome = "Antonio Rocha";
user2->user->tipouser = 3;
user1->prox = user2;
no *user3 = malloc(sizeof (no));
user3->prox = NULL;
user3->user = malloc(sizeof (user));
user3->user->numec = 8020326;
user3->user->pass = "password";
user3->user->nome = "Tiago Gomes";
user3->user->tipouser = 3;
user2->prox = user3;
no *user4 = malloc(sizeof (no));
user4->prox = NULL;
user4->user = malloc(sizeof (user));
user4->user->numec = 8030934;
user4->user->pass = "password";
user4->user->nome = "Barbara Goncalves";
user4->user->tipouser = 3;
user3->prox = user4;
no *user5 = malloc(sizeof (no));
user5->prox = NULL;
user5->user = malloc(sizeof (user));
user5->user->numec = 8040397;
user5->user->pass = "password";
user5->user->nome = "Rosanette Cruz";
user5->user->tipouser = 3;
user4->prox = user5;
no *user6 = malloc(sizeof (no));
user6->prox = NULL;
user6->user = malloc(sizeof (user));
user6->user->numec = 8051234;
user6->user->pass = "password";
user6->user->nome = "Arnaldo Freitas";
user6->user->tipouser = 3;
user5->prox = user6;
no *user7 = malloc(sizeof (no));
user7->prox = NULL;
user7->user = malloc(sizeof (user));
user7->user->numec = 8060672;
user7->user->pass = "password";
user7->user->nome = "Diogo Neves";
user7->user->tipouser = 1;
user6->prox = user7;
no *user8 = malloc(sizeof (no));
user8->prox = NULL;
user8->user = malloc(sizeof (user));
user8->user->numec = 8070427;
user8->user->pass = "password";
user8->user->nome = "Marcio Coelho";
user8->user->tipouser = 3;
user7->prox = user8;
no *user9 = malloc(sizeof (no));
user9->prox = NULL;
user9->user = malloc(sizeof (user));
user9->user->numec = 8080007;
user9->user->pass = "password";
user9->user->nome = "Luis Branco";
user9->user->tipouser = 3;
user8->prox = user9;
no *user10 = malloc(sizeof (no));
user10->prox = NULL;
user10->user = malloc(sizeof (user));
user10->user->numec = 8090023;
user10->user->pass = "password";
user10->user->nome = "Pedro Lobo";
user10->user->tipouser = 3;
user9->prox = user10;
no *user11 = malloc(sizeof (no));
user11->prox = NULL;
user11->user = malloc(sizeof (user));
user11->user->numec = 8090713;
user11->user->pass = "password";
user11->user->nome = "Paulo Lopes";
user11->user->tipouser = 3;
user10->prox = user11;
no *user12 = malloc(sizeof (no));
user12->prox = NULL;
user12->user = malloc(sizeof (user));
user12->user->numec = 8010212;
user12->user->pass = "password";
user12->user->nome = "Elsa Lopes";
user12->user->tipouser = 2;
user11->prox = user12;
no *user13 = malloc(sizeof (no));
user13->prox = NULL;
user13->user = malloc(sizeof (user));
user13->user->numec = 8020001;
user13->user->pass = "password";
user13->user->nome = "Helder Pinto";
user13->user->tipouser = 2;
user12->prox = user13;
no *user14 = malloc(sizeof (no));
user14->prox = NULL;
user14->user = malloc(sizeof (user));
user14->user->numec = 8030028;
user14->user->pass = "password";
user14->user->nome = "Ricardo Santos";
user14->user->tipouser = 2;
user13->prox = user14;
password(username(fst));
}
no *username(no *ptr)
{
int val;
printf("Introduza o user: ");
scanf("%d", &val);
while(ptr != NULL){
if(val==ptr->user->numec){
return ptr;
}
ptr = ptr->prox;
}
}
int password(no *ptr)
{
no* aux = malloc(sizeof(no));
aux->prox = NULL;
aux->user = malloc(sizeof(user));
printf("Introduza a sua pass: ");
scanf("%s", aux->user->pass);
printf("A pass e: %s", aux->user->pass);
}
I have the struct of the lists in a header
build netbeans:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/tp
mkdir -p build/Debug/GNU-MacOSX
rm -f build/Debug/GNU-MacOSX/main.o.d
gcc -c -g -MMD -MP -MF build/Debug/GNU-MacOSX/main.o.d -o build/Debug/GNU-MacOSX/main.o main.c
mkdir -p dist/Debug/GNU-MacOSX
gcc -o dist/Debug/GNU-MacOSX/tp build/Debug/GNU-MacOSX/main.o
BUILD SUCCESSFUL (total time: 271ms)
Cans someone tell me why it isn't reading the string I input?
btw, I'm portuguese .
cumps