write a program for size of a data type without using
sizeof() operator?

Answer Posted / mukesh kumar singh

#include <iostream>
using namespace std;
struct node {
int x;
int y;
char *s;
};
int main()
{


node x,*p;/* here u can change the type */

p=&x;
cout<<"\n\nSize of node Is : "<<(char*)(p+1)-(char*)p;
return 0;
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is malloc and calloc?

820


What is zero based addressing?

946


Why are all header files not declared in every c program?

841


What is a structure in c language. how to initialise a structure in c?

855


Tell us bitwise shift operators?

824


Why void main is used in c?

806


What are predefined functions in c?

797


What is the meaning of ?

826


Difference between pass by reference and pass by value?

891


Are there namespaces in c?

810


explain what is a newline escape sequence?

892


What are near, far and huge pointers?

854


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

1874


can anyone suggest some site name..where i can get some good data structure puzzles???

1863


Describe the header file and its usage in c programming?

844