All Questions
Tagged with variable-assignment pointers
148 questions
13
votes
5
answers
2k
views
How Does the Left-Hand Side (LHS) of an Assignment Evaluate in C?
I’m working on understanding pointers in C by breaking down the language into three key areas: syntax, semantics, and idioms.
To grasp pointers, I’ve been focusing on fundamental concepts:
what’s an ...
-1
votes
1
answer
114
views
Assign an array to a custom made structure [duplicate]
I have this code that assigns an array of 8 elements to a pointer that points to a instance j of a custom structure (Input_Leo).
In CFNN.cpp:
{
double tx_tech_variable_vec[8] = { 0 }; //I need ...
0
votes
1
answer
67
views
Why edditing value using pointer, that is class private field, requires declaring additional variable?
I have defined three simple files:
main.cpp
#include <iostream>
#include "EventHandler.h"
int main(int argc, char *argv[])
{
bool myFlag = true;
EventHandler eventHandler = ...
0
votes
2
answers
116
views
Why after executing function, the address of my pointer change
Here is my code. I want to copy data from a memory region to other memory region. To avoid overlap data i make the order copy, not from the lsb , but from msb of the array like the picture order of ...
0
votes
2
answers
105
views
How do I change contents of a variable using a pointer?
I'm working with pointers for the first time in C. I tried to declare, initialize, and assign a memory address to 3 pointers, then print the addresses and values of each pointer and variable, then ...
0
votes
2
answers
217
views
Why this code returns the following error after compiling "invalid type argument of unary '*' (have 'int')"?
Given a 24bit string included in three 8bit registers, say:
array[0], array[1], array[2]
where the first bit of array[0] is the MSB and the last bit of array[2] is the LSB. My goal is to convert this ...
0
votes
4
answers
641
views
Why is the external pointer causing error? [duplicate]
#include<stdio.h>
int *a,b=9;
a=&b;
void main()
{
//nothing here
}
When I run the above code in C I get 5 errors. They are:-
1) [Warning] data definition has no type or storage class
2)...
1
vote
3
answers
87
views
Is this a correct way to define array of pointers to array?
Is this a correct way to define array of pointers to array in C programming language?
int* ptr[2];
int n1[5] = { 2,3,4,5,6 };
int n2[5] = { 2,3,4,5,6 };
ptr[0] = &n1;
ptr[1] = &n2;
I am ...
-1
votes
1
answer
169
views
"The value is never used" pointer re-assignment C++
I'm refactoring this bit of code:
struct GameState {
PieceState piece;
}
//create local copy from piece, modify it, and only when its VALID copy it back!
void update_game_play(GameState *game, ...
1
vote
1
answer
123
views
how do i point multiple addresses to an array of strings in c?
the mission is to separate the string into several fields. each field is limited by ";", cada campo é armazenado num array de strings
Only PTR[0] is correct. I think it's because of the ...
2
votes
1
answer
198
views
Go assignment involving pointers to custom types
I am using custom types and I have a problem when pointers are involved like below.
Code below is valid:
package main
import (
"fmt"
)
type deck []string
func newDeck(cards ...string) ...
1
vote
1
answer
80
views
Confused with references on pointers in C++
The task is to calculate the output of the following source code without a computer, which I would say is "123 234 678 678" because ref1 is a reference on the value of ptr and in the moment ...
0
votes
2
answers
2k
views
Change char at index from char pointer
I know that the following is invalid:
char *string = "Some String":
string[1] = 'v';//INVALID
But how can I achieve the desired behavior here, without changing the type of string to some ...
2
votes
1
answer
254
views
How do I get my Julia code to assign the scalar value of a variable to an array without changing it as they variable mutates later on?
For my simulation, I have a field that is called particle.current_theta. When this field is a single variable, I assign it a new value that is called just "theta" on my line 177. This theta ...
-1
votes
2
answers
770
views
Get address of double pointer
I'm trying to figure out the correct syntax in this situation:
Assign double pointer to an object
Get the original address of that double pointer back
Here's a code example:
typedef struct obj2{
...