You can’t cast anything to a structure type. What I presume you meant to write is:
dungeon *d1 = (dungeon *)malloc(sizeof(dungeon));
But please don’t cast the return value of malloc()
in a C program.
dungeon *d1 = malloc(sizeof(dungeon));
Will work just fine and won’t hide #include
bugs from you.
Related Posts:
- Incompatible implicit declaration of built-in function ‘malloc’
- What is the cause of flexible array member not at end of struct error?
- How to properly malloc for array of struct in C
- “warning: useless storage class specifier in empty declaration” in struct
- C-like structures in Python
- C-like structures in Python
- typedef struct vs struct definitions [duplicate]
- Why should we typedef a struct so often in C?
- Why should we typedef a struct so often in C?
- typedef struct vs struct definitions [duplicate]
- dereferencing pointer to incomplete type
- Difference between malloc and calloc?
- “error: assignment to expression with array type error” when I assign a struct field (C)
- How do you make an array of structs in C?
- Process finished with exit code 11 | Error during malloc [duplicate]
- Map like structure in C: use int and struct to determine a value
- Difference between a Structure and a Union
- error: expected primary-expression before ‘)’ token (C)
- How to initialize a struct in accordance with C programming language standards
- Need more information about Aborted (core dumped)
- When and why to use malloc?
- size of struct in C
- Warning: assignment from incompatible pointer type
- How do malloc() and free() work?
- How to run valgrind with basic c example?
- Why am I getting this error: “data definition has no type or storage class”?
- difference between
and - Memory Clobbering Error
- malloc: *** error: incorrect checksum for freed object – object was probably modified after being freed
- Use of cudamalloc(). Why the double pointer?
- Uninitialized value was created by a heap allocation
- Allocating string with malloc
- Incorrect checksum for freed object on malloc
- Scanning Multiple inputs from one line using scanf
- What does “request for member ‘*******’ in something not a structure or union” mean?
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Difference between sizeof(char) and sizeof(char *)
- Valgrind Invalid free() / delete / delete[] / realloc() in C
- Initializing array of structures
- Structure padding and packing
- Allocating char array using malloc
- Casting a pointer to an int
- C Unknown type name ‘my_structure’
- typedef struct pointer definition
- How to allocate array of pointers for strings by malloc in C?
- Why and when to use static structures in C programming?
- error: struct has no member named X
- realloc(): invalid next size when reallocating to make space for strcat on char *
- Constructor for structs in C
- malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int))
- How big can a 64 bit unsigned integer be?
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- Implementing Taylor Series for sine and cosine in C
- Working on code to calculate cosine with factorial sum
- How to use execvp()
- How to use execvp() to execute a command
- How does strtok() split the string into tokens in C?
- warning: implicit declaration of function
- warning: implicit declaration of function
- What is *(uint32_t*)?
- What does (~0L) mean?
- pthread_join() and pthread_exit()
- What is size_t in C?
- What is the difference between float and double?
- what is Segmentation fault (core dumped)? [duplicate]
- What causes a segmentation fault (core dump) to occur in C?
- uint8_t vs unsigned char
- How to use symbols of extended ASCII table in C?
- Two questions about basic C programs
- What is the difference between ++i and i++?
- Using boolean values in C
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- How to print in C
- What is the effect of extern “C” in C++?
- Why are #ifndef and #define used in C++ header files?
- Arrow operator (->) usage in C
- strdup() – what does it do in C?
- strdup() – what does it do in C?
- What is a string of hexadecimal digits?
- What exactly is the difference between “pass by reference” in C and in C++?
- What is the difference between ++i and i++?
- What can be the reasons of connection refused errors?
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- What is newline character — ‘\n’
- When to use extern “C” in simple words? [duplicate]
- Floating point exception( core dump
- Why does ENOENT mean “No such file or directory”?
- What does the question mark character (‘?’) mean?
- Cannot figure out how to use getchar(); in C
- Floating point exception (core dumped)
- Undefined reference to pthread_create in Linux
- what is the difference between uint16_t and unsigned short int incase of 64 bit processor?
- makefile:4: *** missing separator. Stop
- Stack smashing detected
- Why am I getting “void value not ignored as it ought to be”?
- Correct format specifier for double in printf