sizeof Questions
5
I'm hoping this isn't a duplicate question, but I've searched in some detail and haven't found my exact case before.
I have a simple struct that I also want to be able to access as a simple byte a...
3
Solved
How can I check the size of an unsigned in the preprocessor under g++? sizeof is out of the question since it is not defined when during preprocessing.
Induce asked 6/4, 2010 at 13:1
2
Solved
Context
The standard says (C17, 6.5.3.4 ¶2):
The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined f...
Trifocal asked 6/4 at 9:30
7
Solved
I have two structures, with values that should compute a pondered average, like this simplified version:
typedef struct
{
int v_move, v_read, v_suck, v_flush, v_nop, v_call;
} values;
typedef st...
16
For now, I am using a static assert (home brewed based on other web resources) to compare the sizeof() result to various constants. While this works, it is far from elegant or fast.
I can also crea...
Seneschal asked 7/1, 2014 at 18:57
17
How do I get the size occupied in memory by an object in Python?
Lovage asked 16/1, 2009 at 5:7
5
Solved
On a microcontroller, in order to avoid loading settings from a previous firmware build, I also store the compilation time, which is checked at loading.
The microcontroller project is build with 'm...
Acanthopterygian asked 15/1 at 12:45
3
Solved
I have the following class,
struct employee {
std::string name;
short salary;
std::size_t age;
};
Just as an example, in Linux amd64, the size of the struct is 48 bytes, and the size of std::st...
7
Solved
Is this the simplest/shortest way to get size in memory of the content of what std::array::data() returns?
arr.size() * sizeof(arr.value_type)
Edit: My question wasn't precise. By "size in memor...
2
Solved
TL;DR
I have a struct with more than just member variables (e.g. they contain functions), and I want to convert only the member variables into a byte array(/vector), such that I can upload data to ...
6
Solved
I just found this code on Wikipedia.
Link: http://en.wikipedia.org/wiki/Sizeof#Use
The code:
/* the following code illustrates the use of sizeof
* with variables and expressions (no parentheses...
9
Solved
This is a C++ interview test question not homework.
#include <iostream>
using namespace std;
enum months_t { january, february, march, april, may, june, july, august, september,
october, ...
6
Solved
I want to be able to vary the size of my array so I create one this way:
int* array;
array = malloc(sizeof(int)*10);//10 integer elements
I can use this like an array as you normally would, howe...
12
Solved
So I have an array of strings. Here's an example:
std::string array[] = {"Example", "Example2", "Example3"};
Is there any way I can find the number of elements in an ...
4
Solved
In order to understand the memory consumption of std::vector<int> I wrote:
std::cout << sizeof(std::vector<int>) << std::endl;
This yields 32. I tried to understand where...
4
Solved
My project demands a complete understanding of how the sizeof operator works. The C standard specification in this regard is vague and it will be dangerous to rely on my interpretations of it. I am...
6
Solved
I'm trying to use 64 bit integers in C, but am getting mixed signals as to whether it should be possible.
When I execute the printf:
printf("Size of long int:%d\nSize of long long int:%d\n\n",(in...
6
Solved
I'm having a look at Go, which looks quite promising.
I am trying to figure out how to get the size of a go struct, for
example something like
type Coord3d struct {
X, Y, Z int64
}
Of course I ...
6
Solved
For what design reason is there no sizeof operator in Java? Knowing that it is very useful in C++ and C#, how can you get the size of a certain type if needed?
Violoncellist asked 1/12, 2011 at 18:21
6
Solved
As the title implies, my question is how to get the size of a string in C. Is it good to use sizeof if I've declared it (the string) in a function without malloc in it? Or, if I've declared it as a...
4
Solved
Well, after reading this Size of structure with a char, a double, an int and a t I still don't get the size of my struct which is :
struct s {
char c1[3];
long long k;
char c2;
char *pt;
char...
5
Solved
13
Solved
1
Solved
I don't understand how sizeof behaves differently when both the lists are created like literals. I expect the output of the second sizeof to be equal or less than that of the first sizeof, not grea...
17
Solved
First off, here is some code:
int main()
{
int days[] = {1,2,3,4,5};
int *ptr = days;
printf("%u\n", sizeof(days));
printf("%u\n", sizeof(ptr));
return 0;
}
Is there a way to find out the...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.