Can I just use:
Code:
struct client {
int id_client;
char name_client;
int cont_client;
struct client *next;
};
typedef struct clien CLIENT;
And, in another function, that asks the user the Name and the Social Security Number:
Code:
void new_client(CLIENT **start)/* I don't know what pointer to use, and how to define a pointer to the start of the file would it be SEEK_SET?.. */ {
CLIENT *walker, *last, *new;
char name_client[100];
int cont_client, id_client, i=0;
last = NULL;
printf("Client's name > ");
while ((ch = getchar()) != '\n')
nome[i++] = ch;
name_client[i] = '\0';
printf("Client's Social Security Number >");
scanf("%d", cont_client); /* I am highly unsure of this, I have no idea, if the numbers go the same way as characters */
clean_buffer(); /* a simple buffer clean up- {
while (getchar() != '\n');
} My teacher told me to use it so, here goes */
And would this be of any use?
Code:
new = (CLIENT*) malloc(sizeof(CLIENT));
new->name_client = malloc(sizeof(char) * strlen(name_client));
strcpy(new->name_client, name_client);
new->cont_client = cont_client;
new->next = NULL;
if (last == NULL) {
*elem = new;
} else {
last->next = new;
}
}
}
Does that even make sense? And what if I want the other variable id_client, to start at 1, and then go up one value for each client that is added? Or, just read the number of clients and would be equal to number of clintes + 1?