Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Here is my question: three .c file is defined , in two file contains structure variable. And another file having array variable which contains name of structure variables.

it is possible to find size of stucture.




C++
//one.c

               void one()
                        {
                          struct a{                    //define structure in .c file
                              int al;
                              char b;
                              };
                             typedef struct a a11;
                         }




C++
  //two.c
                      //define structure variables in .c file
void two()
                          {
                              struct a1{
                                     int c1;
                                       };
                                  typedef struct a1 a111;
                                  struct b1{
                                          char c2;
                                          char g;
                                            };
                                  typedef struct a1 a111;
                            }


here another file three.c,





C++
void main{

 char a[3][10]   //two dimmensional array for storing
                       name of variables.

   printf("%d",sizeof(a[0]))  ;
    }



//which stored structure variables name;
my question is: it is possible to find size of a11,a111 in this file.
Posted
Updated 25-Feb-14 22:27pm
v2
Comments
Krunal Rohit 25-Feb-14 23:10pm    
Format your code here properly.

-KR
Stefan_Lang 26-Feb-14 4:30am    
I've fixed most of the formatting issues for you. Please, next time do use the built-in functionality - it looks like you used some external HTML editor, and that really doesn't work well on this site!

Anyway, at the very least you should verify that the question really looks the way you expected rather than "fire and forget"! There's even a preview at the bottom of the page for entering questions!

1 solution

No.

three.c has no knowledge of the definitions you hid in one.c or two.c. How could they know? That is what headers are for. Read up on headers for C/C++.
 
Share this answer
 
Comments
gupta_abha 27-Feb-14 1:11am    
@permalink: if i decalre in each .h file and include .h files in that file i want to size of the variables then it is possible.
Stefan_Lang 27-Feb-14 2:38am    
As I said - that is what headers are for. It is in fact the very reason C/C++ *needs* header files: to provide information of data types and functions in other parts of the application!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900