C++ program errors? where?

#include <stdio.h>

int main()
{
int number1; //variable declaration


printf("Enter number1: "); //prompt

scanf_s("%d", number1);

printf("Number1 is %d, number1); //display text and value stored in number1

printf("\n"); //displays newline

Return 0;
}
This scanf_s("%d", number1); is the problem. scanf(...) requires a pointer to the variable in order to store the values:

scanf_s("%d", &number1); // Note: &
Registered users can post here. Sign in or register to post.