Questions tagged [variable-address]

The position in memory occupied by a variable, often inside a program made by the user in some programming language. May be passed to a pointer as its value.

Every variable used by a program occupies a certain address inside the memory of the computer it's being executed into. This address is specific to the variable and can't be changed. It will be freed when the variable gets deleted (e.g. if the program or function it's been declared into ends).

This address can be passed to a pointer, so the variable's value can be modified (or passed to functions or other variables) outside the functions it exists into.

10 questions
3
votes
4 answers

why windows use stacks for storing the local variables?

Why C use stacks for storing the local variables? Is this just to have independent memory space or to have feature of automatic clearing of all the local variables and objects once it goes out of scope? I have few more questions around the…
Bhupesh Pant
  • 4,053
  • 5
  • 45
  • 70
2
votes
2 answers

Dereferencing a char pointer in C/C++?

I am working in a program using the DWARF and ELF info. I am hooked to another program using a tool called Pin. I have the addresses from the global variables declared in "Y" program and I hook it into my Pin module which I will call "X". I am…
attis
  • 171
  • 1
  • 4
  • 16
1
vote
1 answer

displaying address of char variable in c++ using pointers?

how can we display the address of char variable? I have found a solution using type casting by fist converting it to int or float or void etc. and then displaying address using pointers. But is there any other alternative to particular solution…
Faisal Naseer
  • 4,110
  • 1
  • 37
  • 55
1
vote
3 answers

What is the purpose of the byte size of the type of a variable if I know the address of the variable?

I am not getting the whole purpose of working with the byte size of a variable by knowing the address of it. For example, let's say I know where an int variable is stored, let's say it is stored in address 0x8C729A09, if I want to get the int stored…
attis
  • 171
  • 1
  • 4
  • 16
0
votes
1 answer

difference in variable assigning in Python between integer and list

I am studying Wes McKinney's 'Python for data analysis'. At some point he says: "When assigning a variable (or name) in Python, you are creating a reference to the object on the righthand side of the equals sign. In practical terms, consider a list…
reza
  • 1
0
votes
2 answers

Am I assigning a value directly to a memory location with a pointer variable in C?

I've decided to complicate my life by learning C. Currently I am trying to fully understand pointers. So far this is what I understand: #include int main() { char var = 'A'; // Iniialize a pointer variable to the ADDRESS of…
howdoicode
  • 779
  • 8
  • 16
0
votes
2 answers

In the sample, why size of `char _Alignas(double)` is not 8?

#include int main(void) { char c1 = '0'; char _Alignas(double) c2 = '0'; printf("char alignment: %zd\n", _Alignof(char)); printf("double alignment: %zd\n", _Alignof(double)); printf("&c1: %p\n", &c1); …
Hongyuan
  • 100
  • 6
0
votes
1 answer

Why am I unable to obtain memory address of char or uint8_t variables in MSVS2019 / C++?

I need to obtain the memory address for some of the variables in my program. I have no issues getting addresses of 2 or 4 byte variables of type short, int, uint32_t, etc. However when I try to get address of 1 byte variable, I get a garbled text on…
parameter2
  • 13
  • 2
0
votes
11 answers

How to get a variable address using a string with variables name?

I would like to do something like a simple and quick general console debugger. This small lib should be embedded to the main program. So I would like to do stuff like this while running the program in console mode: "input: print i" "output:…
0
votes
1 answer

Address of local variable is assigned to member pointer in Structure

struct a { int *val; }; void main(){ int n; struct a *a1; a1= malloc(sizeof(a1)); n=10; a1->val = &n; func(a1); printf("After changing %d\n",a1->val); } void func(struct a *a2){ int a = 5; a2->val =…
shunty
  • 375
  • 2
  • 7
  • 24