Hot answers tagged

3

Yes. The first version typedef struct { // members } Point; defines an anonymous struct (i.e., a struct that doesn't have a name) and gives it a type name (i.e., Point). Unfortunately, if you decide to have a pointer to a recursive member inside your struct this way, you won't be able to do that because as long as you're before the semicolon that ...


1

I think the issue is with this line of code: while (fread(block, sizeof(block), 1, input) == 1) fread returns the number of items successfully read. So, if it successfully reads 1 block of data, it would return 512 and not 1. Since the condition isn't true, the while loop gets skipped and the program exits. Edit: you are also returning 0 upon reading the ...


1

The requirement is that you give the struct a name so you can use it in the declaration. Whether or not that is a different name isn't important. Both of those declarations are fine.


1

You seem to ignore the value of found. Just disables the duplicate check. You don't have a loop for printing elements, and you seem to use ptr before initialisation. I would expect a loop very similar to that one searching for the element, or that one searching for the last node of the list. Like for (node*ptr=numbers;ptr!=NULL;ptr=ptr->next) ...


1

The typedef keyword defines a type synonym for an existing type — it basically defines a new name for an existing type. The original type name and its type synonym can be interchangeably used in your program. The statement typedef struct GWindowCDT *GWindow; basically defines the type synonym GWindow for the existing pointer type GWindowCDT *. Similarly ...


Only top voted, non community-wiki answers of a minimum length are eligible