functions with structures

I am not able to have two functions with same name but different structures as its parameters. Why so?

For e.g.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>

struct temp{
    int a[100];
};

struct struct_type {
  int a, b;
  char ch;
} ;

void f1(struct struct_type parm)
{
  printf("%d", parm.a);
}

void f1(struct temp parm)
{
    printf("%d", parm.a[0]);
}

int main(void)
{
  struct struct_type arg;
  arg.a = 1000;
  f1(arg);
  return 0;
}


Thanks
Depends.
if C - then NO (no function overloading in C)
if C++ then YES.
Your code should work fine in C++. Maybe you are using the C compiler?

How are you compiling this program? Can you give the command you are using?
Topic archived. No new replies allowed.