-1

Main Error:

Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

I have read so many different ones and tried it all with no luck. Could someone help please? I am not a dev, so any help would be really appreciated.

I have tried the linker resolution and several others.

#include <stdio.h>
#include <string.h>

void main()
{
    printf("======================================================================");
    printf("\n====================================================================");

    char input[20];
    int i,j;
    
    puts("\n\nEnter the sentence to be reversed::\n");
    gets(input);
    printf("Input   addr: %p\n", input);
    printf("\nThe reversed sentence is:: \n\n");
    strrev(input);
   
    for(i=0; input[i]!='\0'; i++)
    {
       if(input[i+1]==' ' || input[i+1]==NULL)
       {
           for(j=i; j>=0 && input[j]!=' '; j--)
            printf("%c",input[j]);
       }
       else
       continue;
       printf(" ");
    }
    getch();
}
Centadmin
  • 35
  • 4
  • Did you try this: https://stackoverflow.com/a/46085227/3003365? – kaylum Sep 05 '21 at 23:24
  • are you compiling it as C or C++? From the error it looks like it might be C++, although the code is plain C. Usually `main` is expected to return `int`, not `void`. You may try to change that and see if that makes a difference. Add `return 0;` if you change the return type. – tromgy Sep 05 '21 at 23:59
  • Rather, `int main(void)` or `int main(int, char**)` (that is allowed in both C and C++, with the same meaning). Remember that empty parentheses in C don’t mean what one may expect. – numzero Sep 06 '21 at 00:34
  • Does this answer your question? [Error LNK2019 unresolved external symbol \_main referenced in function "int \_\_cdecl invoke\_main(void)" (?invoke\_main@@YAHXZ)](https://stackoverflow.com/questions/33400777/error-lnk2019-unresolved-external-symbol-main-referenced-in-function-int-cde) – Ivan Barayev Sep 06 '21 at 17:56

1 Answers1

1

Thank you for the replies. So the first problem was in my source file i had a .cpp file rather than a .c file. Then I found that I wasn't exactly pointing to the entry point of my program properly.

So this is now fixed. Thank you to all that replied.

Centadmin
  • 35
  • 4