plz explain how to do this the proper way.

main.c
=====
struct names{  // definitions
-----
----
----
} 

struct names x;

function1(&x);

file2.c
======
function1(struct names *x){
----
----
----

}

am getting warning: 'struct names' declared inside parameter list

Recommended Answers

All 5 Replies

I guess it's

struct names{
// ....
} x;

or put it this way

struct names{
// ...
};

struct names x;

about the warning am saying. any idea ?

You're missing a semi-colon after defining the struct.

Should be:

struct names{  // definitions
-----
----
----
};

its not that i think. i had put a semi-colon there.

It's a good time to remember header files. Place the structure definition in .h file then include it in both main.c and file2.c. Now you have common structure (and other types) definition source.
A compiler knows nothing about main.c contents when processes file2.c.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.