I'm new at c programming, and during my learnings, lately I've started to deal with Linked lists. In this program that I wrote, i keep getting this message( LNK2019 error):
unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
What I'm trying to do is to create a linked list, and use a function to input values into this list, using the main.
this is the full code I wrote:
#include <stdio.h>
#include <stdlib.h>
typedef struct Original_list
{
int data;
struct Original_list *next;
}original_list;
original_list *Input();
void EX2()
{
original_list *list;
list = Input();
}
original_list *Input()
{
original_list *lst, *curr_point;
int c;
printf("Please enter a value to the first data: \n");
scanf_s("%d", &c);
if (c < 0)
return NULL;
lst = (original_list*)malloc(sizeof(original_list));
curr_point = lst;
lst->data = c;
while (c >= 0)
{
curr_point->next = (original_list*)malloc(sizeof(original_list));
curr_point = curr_point->next;
curr_point->data = c;
printf("please enter number(scan will stop if a negative number is scanned): \n");
scanf_s("%d", &c);
}
curr_point->next = NULL;
return lst;
}
I can't see any definition I did wrong or any problem justifying this error.
please help!
thank you very much!
Your code lacks an entry point. For C/C++ it is usually main()
, that's what the error is about.