![vex robotc tutorial vex robotc tutorial](http://botbench.com/blog/wp-content/uploads/2014/05/robotc-4-screenshot-400px.png)
Should you want to access this address in ROBOTC, you can do so with the reference (&) operator. This chunk has an address, a number, much like a house. Getting to the point(er)Īs I mentioned earlier, when a variable is declared, the compiler assigns an appropriately sized chunk of memory to it. What happens when we increment i? Does it change j’s rvalue? In short, no, the two rvalues are completely separate entities. However, what happens on the line “j = i”? Simple, the rvalue of i is copied and assigned to j’s rvalue.
![vex robotc tutorial vex robotc tutorial](http://www.mrjopp.com/uploads/5/2/5/3/5253521/4188325.jpg)
On the first assignment, i’s rvalue is given the value 10, on the second assignment, j’s rvalue is given the value 51. When looking at the memory locations and their contents after each operation, it would look something like this: The output of this program should look like this: i: 10, j: 51 WriteDebugStreamLine("i: %d, j: %d", i, j) Now consider this bit of code: // ptr tutorial example 1 As you can guess, the rvalue is the part of the right side of the assignment and lvalue is the part on the left side. You see the memory blocks, the labels assigned to them, their contents and the addresses (the hex numbers under the blocks).Ī variable has two parts, an rvalue and an lvalue.
![vex robotc tutorial vex robotc tutorial](https://jschoolcraft.github.io/robotc-programming-tutorial/images/ch1/Moving_Forward_Sample_Program_in_Editor.png)
An int is 4 bytes large, a float is also 4 bytes but a string (in the case of ROBOTC) is usually 20 bytes large. In effect, when you declare a variable, the compiler puts aside an appropriately sized amount of memory and gives it a symbolic name, like i or f or baz. Up until now, ROBOTC only supported normal variables in other words, a variable, be it an int, float or anything else, only had a value, like 712, 0.383 or “howdy”. This tutorial is the first of a couple that will show you the kinds of things you’ll be able to do with pointers. Hurray, ROBOTC has support for pointers! “That’s nice,” I hear you say, “but what are they?” That’s a good question.