What am I doing wrong?

I am trying to write a simple program that asks a user to enter a year, and the program will take the year and return an integer value. I am trying to accomplish it by calling a function though. Here's what I have:


#include <cstdio>
#include <cstdlib>

void getyear();
void main()
{
int year;


getyear(year);

system ("pause");
}

void getyear(int y)
{
printf("enter a year:\n");
scanf("%d",& y);
return y;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <cstdio>
#include <cstdlib>

void getyear(int y);
int main()
{
     int year;
     printf("enter a year:");
     scanf("%d",&year);fflush(stdin);
     getyear(year);
     getchar();
     return 0;
}

void getyear(int y)
{
    printf("%d",y);
}
Last edited on
Topic archived. No new replies allowed.