Last active
June 14, 2022 14:20
-
-
Save Sarverott/707ebb1c6f37f2bee1dbd094ab963900 to your computer and use it in GitHub Desktop.
prints variable types sizes in var, tab and point variant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
template<typename V> void varPrint(char *name, V x, int len){ | |
V xT[len], *xX=xT; | |
cout | |
<<name | |
<<endl | |
<<"\t variable="<<sizeof(x) | |
<<" bytes table="<<sizeof(xT) | |
<<" bytes pointer="<<sizeof(xX) | |
<<" bytes" | |
<<endl; | |
} | |
int main() | |
{ | |
cout<<"\n\t---| VARIABLES sizes |---\n\t\t\ttest tables size: "; | |
int len=0; | |
cin>>len; | |
long double ld; | |
float f; | |
short s; | |
int i; | |
long l; | |
double d; | |
char c; | |
bool b; | |
varPrint("BOOL", b, len); | |
varPrint("SHORT", s, len); | |
varPrint("CHAR", c, len); | |
varPrint("INT", i, len); | |
varPrint("FLOAT", f, len); | |
varPrint("LONG", l, len); | |
varPrint("DOUBLE", d, len); | |
varPrint("LONG DOUBLE", ld, len); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment