sizeof Questions
22
I want to know the size occupied by a JavaScript object.
Take the following function:
function Marks(){
this.maxMarks = 100;
}
function Student(){
this.firstName = "firstName";
this.lastName ...
Jemison asked 8/8, 2009 at 7:58
3
Solved
I am trying to allocate AVFrame->data[0] of a video frame to uint8_t* buffer using the following lines of code :
size_t sizeOfFrameData = mpAVFrameInput->linesize[0] * mpAVFrameInput->heig...
4
Solved
Sizeof() doesn't work when applied to bitfields:
# cat p.c
#include<stdio.h>
int main( int argc, char **argv )
{
struct { unsigned int bitfield : 3; } s;
fprintf( stdout, "size=%d\n", s...
Endurant asked 23/7, 2010 at 15:32
1
Consider
int array[5]{};
std::cout << std::size(array) << std::endl;
This will give me the result of 5.
int array[5]{};
std::cout << sizeof(array) << std::endl;
This will ...
3
Solved
14
Solved
Let's say I have an array arr. When would the following not give the number of elements of the array: sizeof(arr) / sizeof(arr[0])?
I can thing of only one case: the array contains elements that a...
5
I wrote a bash script to determine the size of gcc's datatypes (e.g. ./sizeof int double outputs the respective sizes of int and double) by wrapping each of its arguments in the following P() macro...
10
Solved
I have tried implementing the sizeof operator. I have done in this way:
#define my_sizeof(x) ((&x + 1) - &x)
But it always ended up in giving the result as '1' for either of the data type....
Modie asked 5/1, 2013 at 11:1
4
Solved
The program
#include <stdio.h>
int main(void) {
printf("sizeof( char ) = %zu, sizeof 'a' = %zu.\n", sizeof( char ), sizeof 'a' );
return 0;
}
outputs the following:
sizeof(...
5
Solved
For example result of this code snippet depends on which machine: the compiler machine or the machine executable file works?
sizeof(short int)
Pollypollyanna asked 10/4, 2010 at 22:15
1
Solved
If sizeof(int) == sizeof(long), then is INT_MIN == LONG_MIN && INT_MAX == LONG_MAX always true?
Is there any real existing cases demonstrating "not true"?
UPD. The similar questio...
8
Solved
When looking for a size of an array in a for loop I've seen people write
int arr[10];
for(int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++){}
How is sizeof(arr) / sizeof(arr[0]) the length of...
10
Solved
Here is the code compiled in Dev-C++ on Windows:
#include <stdio.h>
int main() {
int x = 5;
printf("%d and ", sizeof(x++)); // note 1
printf("%d\n", x); // note 2
ret...
16
I have an int array and I need to find the number of elements in it. I know it has something to do with sizeof but I'm not sure how to use it exactly.
8
What's the difference between sizeof and alignof?
#include <iostream>
#define SIZEOF_ALIGNOF(T) std::cout<< sizeof(T) << '/' << alignof(T) << std::endl
int main(int...
4
Solved
In C, I have an array of structs defined like:
struct D
{
char *a;
char *b;
char *c;
};
static struct D a[] = {
{
"1a",
"1b",
"1c"
},
{
"2a",
"2b",
"2c"
}
};
I would like to determ...
4
Solved
Following the question: How come an array's address is equal to its value in C?
#include <stdio.h>
#define N 10
char str2[N]={"Hello"};
int main(){
printf("sizeof(str2): %d bytes\n", s...
0
The following program
template<int>
struct R{};
struct S
{
template<typename T>
auto f(T t) -> R<sizeof(t)>;
};
template<typename T>
auto S::f(T t) -> R<sizeof...
Alteration asked 10/4, 2021 at 21:38
7
Solved
I have two tasks for an assignment, one return the number of bits in type int on any machine. I thought I would write my function like so:
int CountIntBitsF() {
int x = sizeof(int) / 8;
return x...
2
Solved
I have the next two code examples:
const char *val = strchr(ch, ' ');
const int diff = (int)(val - ch);
char arr[diff];
and
const char *val = strchr(ch, ' ');
const int diff = (int)(val - ch);
c...
Sylvanus asked 10/3, 2021 at 14:8
5
Solved
Using the sizeof operator, I can determine the size of any type – but how can I dynamically determine the size of a polymorphic class at runtime?
For example, I have a pointer to an Animal, and I...
Engender asked 11/9, 2009 at 15:59
7
Why do we say sizeof(variable) is an operator, not a function?
It looks like a function call and when I am thinking about the meaning of operator, it appears to me something like + or - or * and so...
Cruz asked 22/1, 2021 at 15:41
4
Solved
Suppose I have two classes that I would expect to have exact same memory layout:
struct A {
int x;
int y;
};
/* possibly more code */
struct B {
int a;
int b;
};
Is there anything in the s...
Kaolin asked 8/3, 2019 at 18:0
6
Solved
i have a doubt regarding sizeof operator
Code 1:
int main()
{
int p[10];
printf("%d",sizeof(p)); //output -- 40
return 0;
}
Code 2:
int main()
{
int *p[10];
printf("%d",sizeof(*p)); //out...
4
Solved
On my machine, the relevant sizes are:
sizeof(char) == 1, sizeof(int) == 4 and sizeof(char*) == 8.
#include <stdio.h>
#include <stdlib.h>
typedef struct person{
char *name;
int age;...
© 2022 - 2024 — McMap. All rights reserved.