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))
- What is the effect of extern “C” in C++?
- What exactly is the difference between “pass by reference” in C and in C++?
- What does “collect2: error: ld returned 1 exit status” mean?
- Floating point exception (core dumped)
- Correct format specifier for double in printf
- Compiler Error “void value not ignored as it ought to be” in C programming [duplicate]
- Scanf/Printf double variable C
- How to convert a string to integer in C?
- What is the difference between char s[] and char *s?
- Error “initializer element is not constant” when trying to initialize variable with const
- Cannot assign requested address – possible causes?
- need help understanding the movzbl call in this function
- How to extract C source code from .so file?
- C dynamically growing array
- How to printf “unsigned long” in C?
- Why do I get an assertion failure?
- Difference between int32, int, int32_t, int8 and int8_t
- The Definitive C Book Guide and List[
- When is it a good idea to use strdup (vs malloc / strcpy)
- expression must have integral type
- Why is %c used in C?
- What is Innermost loop in imperfectly nested loops?
- What’s wrong with my code? What is argv[1]?
- C++ Expression must have pointer-to-object type
- (.text+0x20): undefined reference to `main’ and undefined reference to function
- I’m getting “Invalid Initializer”, what am I doing wrong?
- Warning/error “function declaration isn’t a prototype”
- Error: initializer element is not computable at load time
- %i or %d to print integer in C using printf()?
- How can I get the list of files in a directory using C or C++?
- How to convert const char* to char* in C?
- C subscripted value is neither array nor pointer nor vector when assigning an array element value
- error: too few arguments to function `printDay’ (C language)
- Implementing a HashMap in C
- Optional arguments in C function
- Which of sprintf/snprintf is more secure?
- Where is the
header file on Linux? Why can’t I find ? - Why is the sizeof(int) == sizeof(long)?
- Struct inheritance in C++
- Why are there no hashtables in the C standard library?
- Reasoning behind C sockets sockaddr and sockaddr_storage
- What primitive data type is time_t? [duplicate]
- How to format strings using printf() to get equal length in the output
- lseek/write suddenly returns -1 with errno = 9 (Bad file descriptor)
- Should I use printf(“\n”) or putchar(‘\n’) to print a newline in C?
- GDB no such file or directory
- Level vs Edge Trigger Network Event Mechanisms
- How to convert integers to characters in C?
- variably modified array at file scope in C
- How to use random() in C [duplicate]