I want to create my own variable length parameters function it should work like printf() function.
When i write the program as given below it's working fine
Expand|Select|Wrap|Line Numbers
- #include<stdio.h>
- void main()
- {
- void fun(int, ...);
- fun(1,2);
- }
- void fun(int a,int b)
- {
- printf("%d%d",a,b);
- }
- but if i write the progran as given below it's not working it's giving error.
- #include<stdio.h>
- void main()
- {
- void fun(int, ...);
- fun(1,2);
- fun(1,2,3);
- }
- void fun(int a,int b)
- {
- printf("%d%d",a,b);
- }
- void fun(int a,int b,int c)
- {
- printf("%d%d%d",a,b,c);
- }
error C2084: function 'void __cdecl fun(int ,... )' already has a body
My Questions is Why it's giving error?
We can write many printf functions with different argument lists in a single block, How printf() is working and why my fun() is not working?
please answer to my questions