0

The system keeps telling me that I do not have enough arguments to format the string, I am also getting a

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

I do not know what this means. please help.

#include<stdio.h>
#include<stdlib.h>


 Main() {

    int score, sum = 0;
    printf("Enter a test score (-1 to quit):");
    scanf_s("%i", &score);

    while (score != -1) {
        sum = sum + score;
        printf("Enter a test score (-1 to quit):");
        scanf_s("%i", &score);
    }
    printf("\n(The sum of the scores is): %i\n");
        system("pause");
} 
ad absurdum
  • 19,498
  • 5
  • 37
  • 60
Don
  • 15
  • 1
  • 4
  • 3
    Isn't the error message self explanatory? `printf("\n(The sum of the scores is): %i\n");` requires one more parameter to specify where the `%i` comes from: `printf("\n(The sum of the scores is): %i\n", sum);` – kaylum Oct 17 '16 at 00:10
  • 3
    For the second error, `Main` needs to be `main` as C is case sensitive. And you may as well declare it completely: `int main(void)` or `int main(int argc, int **argv)` – kaylum Oct 17 '16 at 00:12
  • Every C book should include these basics. You should read one. In addition to the documentation of functions you use. – too honest for this site Oct 17 '16 at 00:29

1 Answers1

0

First of all, the execution of every C program starts with main() function and the error is in line 1.

So replace Main() with main() as C is case sensitive.

Now scanf_s() required one more argument as Buffer size. User is allowed to give the input upto that size only.

For example, scanf_s("%i",&score,2);

For more info about scanf_s, click here and here

And if you will replace scanf_s() with scanf(), it will work too.

Hope it will help!

Community
  • 1
  • 1
Harshil Doshi
  • 3,497
  • 3
  • 14
  • 37