[Question]
  [
I'm trying to read 4 ints in C in a golfing challenge and I'm bothered by the length of the code that I need to solve it:
```
scanf("%d%d%d%d",&w,&x,&y,&z)
```
that's 29 chars, which is huge considering that my total code size is 101 chars. I can rid of the first int since I don't really need it, so I get this code:
```
scanf("%*d%d%d%d",&x,&y,&z)
```
which is 27 chars, but it's still lengthy.
So my question is, is there any other way (tricks, functions, K&R stuff) to read ints that I don't know of that could help me reduce this bit of code?
---
Some users have reported that my question is similar to [Tips for golfing in C](https://codegolf.stackexchange.com/questions/2203/tips-for-golfing-in-c)
While this topic contain a lot of useful information to shorten C codes, it isn't relevant to my actual use case since it doesn't provide a better way to read inputs.
I don't know if there is actually a better way than scanf to read multiple integers (that's why I'm asking the question in the first place), but if there is, I think my question is relevant and is sufficiently different than global tips and tricks.
If there is no better way, my question can still be useful in the near future if someone find a better solution.
I'm looking for a full program (so no function trick) and all libraries possible. It needs to be C, not C++. Currently, my whole program looks like this:
```
main(w,x,y,z){scanf("%*d%d%d%d",&x,&y,&z)}
```
Any tricks are welcome, as long as they shorten the code (this is code golf) and work in C rather than C++.
  
[Answer]
Thanks to @DialFrost for drawing my attention to this question.
I believe for reading 4 numbers your solution is optimal. However, I found a solution that saves bytes when reading 5 or more numbers at a time.
It will also consume the entire input (i.e. it can't be used in a loop).
Depending on the context it might help you with only 4 variables too
If you define your variables in a sequence like this:
```
a,b,c,d,e;main(){
```
In this case, the variables will be layed out in successive memory addresses, we can abuse that.
```
for(;~scanf("%d",&a+e);e++);
```
Full program:
```
// new
a,b,c,d,e;main(){for(;~scanf("%d",&a+e);e++);}
// original
a,b,c,d;main(e){scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);}
```
This 29 byte segment will paste all the input in successive variables starting in `a`. We re-use `e`, (the last variable) as the index variable. This saves declaring one variable.
## Size comparison
| Number of inputs | Original | New | Original (full program) | new (full program) |
| --- | --- | --- | --- | --- |
| 1 | 14 | 28 | 24 | 38 |
| 2 | 19 | 28 | 31 | 40 |
| 3 | 24 | 28 | 38 | 42 |
| 4 | 29 | 28 | 45 | 44 |
| 5 | 34 | 28 | 52 | 46 |
| 6 | 39 | 28 | 59 | 48 |
Note that the new method gains a 1 byte disadvantage in full programs because you can't use function arguments, however, this doesn't matter if you can use another variable as the argument to `main`.
Note there is also a slot in the initialization portion of the for loop. If you can put another expression there this method can save 1 byte even with only 4 arguments.
[Try it online!](https://tio.run/##S9YtSU7@n6iTpJOsk6KTap2bmJmnoVn9Py2/SMPawKY4OTEvTUNJNUVJRy1RO1XTOlVbW9P6f0FRZl4JWBwGlXTgZmha1/43VDBSMFYwUTAFAA "C (tcc) – Try It Online")
@JDT ponted out you can save 1 byte at the cost of having 1 added to `e` at the end:
```
for(;0<scanf("%d",&a+e++););
```
[Answer]
If you want to e.g. print all the inputs then we have this, being 64 bytes long:
```
main(x,y,z){scanf("%*d%d%d%d",&x,&y,&z);printf("%d%d%d",x,y,z);}
```
We can actually shorten this with a loop, bringing the total down to 47 bytes:
```
main(z){for(;scanf("%d",&z)>0;)printf("%d",z);}
```
So the reading part is only [23 bytes long](https://tio.run/##S9YtSU7@/z83MTNPo0qzOi2/SMO6ODkxL01DSTVFR0lHrUrTzsBas6AoM68ELKakU6VpXfv/v6EOGAIA):
```
for(;scanf("%d",&z)>0;)
```
Note that this only works when you don't want to assign a value to a specific variable and only want to **read** the values.
[A method that is 29 bytes long](https://tio.run/##S9YtSU7@n6iTpJOsk6KTaZ2bmJmnoVn9Py2/SMO6ODkxL01DSTVFR0lHLVE7U9POwDpTW1vT@n9BUWZeCVgKApV0oEZoWtf@N9Qx0jHWMQEA):
```
for(;scanf("%d",&a+i)>0;i++);
```
Shout out to @mousetail for helping me out!
[Answer]
# [C (gcc)](https://gcc.gnu.org/),  ~~44~~  43 bytes
```
main(i,a,b,c,d){for(;i+=scanf("%d",i+&i););
```
[Try it online!](https://tio.run/##Pc3BCsIwEATQe75iCRiSdku19bb4MenGlAUbJa0n8deNWqnMHN8w3IzMpUxekhX0OCBjcI94zZakPs3sU7R6FzRKbcSRo9JWanW0jj74j37RaDyaAQ2jCY5U1apblrRE@BrYqhG2O4J8Xu45wZ6e5QAd9HB8cbz4cS7N1Hdv "C (gcc) – Try It Online")
This frees up an extra integer `i=0`, while [mousetail's solution](https://codegolf.stackexchange.com/a/252554/76323) make `i=5`(can't find a compiler that allow reusing `e` as index without adding extra 1)
Need `-m32` maybe because on x64 values are passed via registers
# [C (tcc)](http://savannah.nongnu.org/projects/tinycc), 44 bytes
```
a,b,c,d,i;main(){for(;i+=scanf("%d",i+&a););
```
[Try it online!](https://tio.run/##Tc1NCgIxDEDhfU8RCpZmJjL@7YKHyaQWsrBKravBs1dwRORtP3i6baq9C82klMj4KlYiLvlWI9t4fqiUHP0mebIxCDJynwb38atNuPzQmqcgFGYKSiEhu2Fy92qlZfg38H0iQ720Zy2w41ffwwGOcHoD "C (tcc) – Try It Online")
]