It looks like the line
head = (Node*) malloc( sizeof( Node ) ); //line 21
is outside the main()
function. You can’t do that, because you can’t execute code outside functions. The only thing you can do at global scope is declaring variables. Just move it inside the main()
or any other function, and the problem should go away.
(PS: Take a look at this question on why you shouldn’t type-cast malloc
)
Related Posts:
- typedef struct pointer definition
- 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]
- Pointer Arithmetic
- dereferencing pointer to incomplete type
- char *array and char array[]
- C pointers and arrays: [Warning] assignment makes pointer from integer without a cast
- How do you make an array of structs in C?
- Difference between a Structure and a Union
- Difference between char* and const char*?
- #31 expression must have integral type
- How do you pass a function as a parameter in C?
- Invalid pointer error on invoking free() after malloc in C
- How to initialize a struct in accordance with C programming language standards
- expression must have integral type
- Incompatible implicit declaration of built-in function ‘malloc’
- What’s wrong with my code? What is argv[1]?
- Valgrind: Invalid read of size 1
- Constant pointer vs Pointer to constant
- What is the cause of flexible array member not at end of struct error?
- Reversing a string in C
- size of struct in C
- Warning: return from incompatible pointer type in C
- Warning: assignment from incompatible pointer type
- strcmp giving segmentation fault
- warning: passing argument ’from incompatible pointer type [enabled by default]’
- char pointers: invalid conversion from ‘char*’ to ‘char’?
- What is the difference between char array and char pointer in C?
- Scanning Multiple inputs from one line using scanf
- Dereference void pointer
- The difference between char * and char[] [duplicate]
- lvalue required as increment operand
- How big can a 64 bit unsigned integer be?
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- 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*)?
- pthread_join() and pthread_exit()
- 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
- Arrow operator (->) usage 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’
- 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
- Stack smashing detected
- How do I determine the size of my array in C?
- Why am I getting “void value not ignored as it ought to be”?
- 1 = false and 0 = true?
- c stack smashing detected
- What does “dereferencing” a pointer mean?
- Openssl : error “self signed certificate in certificate chain”
- How to convert a string to integer in C?
- What is the difference between C and embedded C?
- What does “dereferencing” a pointer mean?
- Get a substring of a char* [duplicate]
- How do I create an array of strings in C?
- Undefined reference to pthread_create
- What is the behavior of integer division?
- Convert char to int in C and C++
- Get a substring of a char*
- Difference between malloc and calloc?
- What is Bit Masking?
- How do function pointers in C work?
- Expression must be a modifiable L-value
- What causes the Broken Pipe Error?
- segmentation fault : 11
- Strings and character with printf
- Awesomium sdk download
- What is EOF in the C programming language?
- What are .a and .so files?
- Why does the terminal show “^[[A” “^[[B” “^[[C” “^[[D” when pressing the arrow keys in Ubuntu?