Challenge: Pointer Arithmetic
Uppgift
Swipe to start coding
Sometimes in programming, you may want to access the value of a variable indirectly using a pointer.
In this task, you will write a function that starts with one variable, moves a pointer to another variable, and returns the value stored there.
- Calculate the distance between the two pointers by subtracting the address of
p_startfrom the address ofp_target. - Add this difference to the
p_startpointer. This gives you a pointer to the value stored inp_target. - Return the value pointed to by
p_start.
Lösning
solution.cpp
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 2
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 5.88
Challenge: Pointer Arithmetic
Svep för att visa menyn
Uppgift
Swipe to start coding
Sometimes in programming, you may want to access the value of a variable indirectly using a pointer.
In this task, you will write a function that starts with one variable, moves a pointer to another variable, and returns the value stored there.
- Calculate the distance between the two pointers by subtracting the address of
p_startfrom the address ofp_target. - Add this difference to the
p_startpointer. This gives you a pointer to the value stored inp_target. - Return the value pointed to by
p_start.
Lösning
solution.cpp
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 2
single