int main() { std::cout << "size of uintptr_t: " << sizeof(uintptr_t) << std::endl; uintptr_t n =10; uintptr_t a[10] = {1,2,3,4,5,6,7,8,9,10}; uintptr_t b[20]; std::cout << "n address: " << &n << std::endl; std::cout << "a address: " << &a << std::endl; std::cout << "b address: " << &b << std::endl; // label the addresses you want to examine on the stack label_stack(&n,"n"); label_stack(&a[0],"a[0]"); label_stack(&a[9],"a[9]"); label_stack(&b[0],"b[0]"); label_stack(&b[19],"b[19]"); // print the range of the stack containing these addresses print_stack(); compute_square(a,b,n); print_stack(); // clear the previous labels clear_stack_labels(); return 0; }
int main() { std::cout << "The size of Time instance is " << sizeof(Time) << std::endl; Time t060000(6, 0, 0); Time t120000(12, 0, 0); std::cout << "Before calling - IN MAIN" << std::endl; label_stack((uintptr_t *)&t060000, "t060000"); label_stack((uintptr_t *)&t120000, "t120000"); print_stack(); change_times(t060000, t120000); std::cout << "after calling - IN MAIN " << std::endl; print_stack(); return 0; }
void change_times(Time& t1, Time t2) { label_stack((uintptr_t *)&t1, "t1"); label_stack((uintptr_t *)&t2, "t2"); std::cout << "Before calling - IN change_times" << std::endl; print_stack(); t1.setHour(15); t1.setMinute(20); t1.setSecond(21); t2.setMinute(50); std::cout << "after calling - IN change_times " << std::endl; print_stack(); }
int main() { // ------------------------------ // Example code using print_stack // ------------------------------ // std::cout << "size of uintptr_t: " << sizeof(uintptr_t) << std::endl; // uintptr_t x = 72; // uintptr_t a[5] = {10, 11, 12, 13, 14}; // uintptr_t *y = &x; // uintptr_t z = 98; // std::cout << "x address: " << &x << std::endl; // std::cout << "a address: " << &a << std::endl; // std::cout << "y address: " << &y << std::endl; // std::cout << "z address: " << &z << std::endl; // label the addresses you want to examine on the stack // label_stack(&x,"x"); // label_stack(&a[0],"a[0]"); // label_stack(&a[4],"a[4]"); // label_stack((uintptr_t*)&y,"y"); // label_stack(&z,"z"); // print the range of the stack containing these addresses // print_stack(); // clear the previous labels // clear_stack_labels(); // continue with lab exercises uintptr_t a[5] = {1, 2, 3, 4, 5}; uintptr_t b[5]; // std::cout << "Before computing : " << std::endl; // print_arr(a, 5); // print_arr(b, 5); std::cout << "a address: " << a << std::endl; std::cout << "b address: " << b << std::endl; std::cout << "value at " << a << " is " << *a <<std::endl; std::cout << "value at " << b << " is " << *b <<std::endl; label_stack(a,"a[0]"); label_stack(a + 4,"a[4]"); label_stack(a + 5,"a[5]"); label_stack(b,"b[0]"); label_stack(b + 4,"b[4]"); label_stack(b + 5,"b[5]"); print_stack(); std::cout << "Before calling " << std::endl; compute_squares(a, b, 10); std::cout << "After calling " << std::endl; print_stack(); }