How to | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

How to

How to make sizeof (dataInput); look at the number or text in dataInput and not the variable itself(4bytes)? Edit: I am trying to make: sizeof (dataInput); calculate the size of the data that the variable "writes"(e.g. : int dataInput="int"; sizeof (dataInput); // size of int not dataInput. Edit2. dataInput is a string (e.g. int)

11th Oct 2016, 4:58 AM
Evgeny Vereshchagin
Evgeny Vereshchagin - avatar
3 Antworten
+ 2
Sadly this is impossible in C++. The closest you can get is making a map of all types yourself and then look up the answer.
11th Oct 2016, 7:27 AM
Schindlabua
Schindlabua - avatar
0
I don't think your question is clearly stated. please give an example or more info on what you are trying to accomplish. And the statement "4 bytes" at the end means what?
11th Oct 2016, 5:23 AM
DevCoder (John Sullivan)
DevCoder (John Sullivan) - avatar
0
I think you want to print no.of items instead of variable size.. if it so... for example a[5]={1,2,3,4,5}; then try cout<<sizeof(a)/size of(a[1]);
11th Oct 2016, 5:51 AM
Balaji Rs
Balaji Rs - avatar