output scanf's input to function

I want to output scanf's input to function.
Not sure if this is possible but couldn't find at google my answer.

1
2
3
4
5
6
#include <stdio.h>
void main()
{
printf("%d\n",scanf("%d"));
return 0;
}


That won't be possible because scanf takes in input and puts it in the memory address of a variable. It doesn't itself return the input.

This code will work:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>

int main()
{
    int x;
    scanf("%d",&x);
    printf("%d\n", x);
    
    return 0;
}


Also, when you return 0, you need to declare main()'s type as int not void.
Topic archived. No new replies allowed.