For example if you enter 100 it's a bad input so the program prints the error message and returns you to the main menu without pressing any buttons.
Type: Posts; User: drew99
For example if you enter 100 it's a bad input so the program prints the error message and returns you to the main menu without pressing any buttons.
Without fgetc(stdin), if you enter a bad code in numbers the program jumps over
fputs("\n------------------------ Premere un tasto per continuare ----------------------\n", S_OUT);...
This is my main:
#define FLUSH(stream) fgets(buff, 256, stream);
#define S_OUT stderr
void apri(articolo **start);
void inserisci(articolo **start);
void cerca(articolo **start);
There is no need to be offensive, I'm a novice programmer and these are the situations that I can not fully manage, so I apologize if I ask you to do more work for me.
What sense phrases like...
Can you write a short pratical example, please?
I've tried in this way, but it still not working:
void apri(articolo **start);
void inserisci(articolo **start);
void cerca(articolo **start);
void modifica(articolo **start);
void...
Ok, but if there aren't any chars in the buffer, the program pauses itself until enter key is pressed...
Ok, so in general if I pass this parameter to a function, what will the function receive?
void my_function(char *name, struct *my_struct)
{
//code
}
Yeah, but it doesn't work, because if I set to 0 the pointer start in one of those functions, in the main function it returns to its original value...
Another question: is it possible to eliminate start as a global variable and pass it as an argument to any function considering that they are called in this way:
Code:
void apri(articolo...
I think every programmer tries to write efficient code and not just follow a book.
I can not just remove fflush (stdin), but I should replace it only if I found woking alternatives.
I just don't understand this obstinacy against goto.
I agree that they involve a minor maintainability if it's relate to a possible repetition of instructions very far or it replaces nested loops,...
I prefer:
Foo *allocate_object()
{
Foo *f;
if ((f = malloc(sizeof *f)) == NULL)
{
I'm making some global changes thanks to your advices and I was wondering if it was possible to eliminate start as a global variable and pass it as an argument to any function considering that they...
I'm making some global changes thanks to your advices and I was wondering if it was possible to eliminate start as a global variable and pass it as an argument to any function considering that they...
Can you tell me what are the advantages of using cycles instead of goto?
Looking at the assembly produced by isolating a small portion with a menu, there seems to be no substantial differences, even...
Can you post a solution without gotos, thanks?
I've done more test and I've found that the program returns an error when I try to delete the first element of the list, so the case 2 can't work!
How is it possible that the program doesn't allow...
Ok:
for(p = start, c = 0; p; p = c);
{
c = p->n;
free(p->name);
free(p->des);
free(p);
Thanks to all, but what are the alternatives for goto and how can I resolve the problem with free()?
char *n_name = (char*) calloc(NAME_LENGTH, sizeof(char)), *n_des = (char*) calloc(DES_LENGTH, sizeof(char));
Your second correction is true but the for fails at the first cicle.
Hello!
This is the problem: when I try to delete all the elements of a linked list the program returns an error while it doesn't when I do the same with only one element of the list.
Here's the...
I've tried to print them and for each union the value is correct: bk8 = 8, bk32 = 32, bk128 = 128 (sizeof)
#include <stdbool.h>
Sorry, I made a mistake during the transcription, Now I've fixed it.