Exemple #1
0
int main(int argc, char *argv[])
{
    // test out THE_AGE accessors
    log_info("My name: %s, age: %d", MY_NAME, get_age());

    set_age(100);

    log_info("My age is now: %d", get_age());

    // test out THE_SIZE extern
    log_info("THE_SIZE is: %d", THE_SIZE);
    print_size();

    THE_SIZE = 9;

    log_info("THE_SIZE is now: %d", THE_SIZE);
    print_size();

    //test the ratio function static
    log_info("Ratio at first: %f", update_ratio(2.0));
    log_info("Ratio again: %f", update_ratio(10.0));
    log_info("Ratio once more: %f", update_ratio(300.0));

    // test the scope demo
    int count = 4;
    scope_demo(count);
    scope_demo(count * 20);

    log_info("count after calling scope_demo: %d", count);

    return 0;
}
Exemple #2
0
int main(int argc, char *argv[])
{
	log_info("My name: %s, age: %d", MY_NAME, get_age());

	set_age(100);

	log_info("My age is now: %d", get_age());

	log_info("THE_SIZE is; %d", THE_SIZE);
	print_size();

	THE_SIZE = 9;

	log_info("THE SIZE is now: %d", THE_SIZE);
	print_size();

	log_info("Ratio at first: %f", update_ratio(2.0));
	log_info("Ratio again: %f", update_ratio(10.0));
	log_info("Ratio once more: %f", update_ratio(300.0));

	int count = 4;
	scope_demo(count);
	scope_demo(count * 20);
	
	log_info("count after calling scope_demo: %d", count);
	
	log_info("The value of ratio is : %f", *RATIO_PTR);

	test_func();
	log_info("The value of x outside test_func is : %d", *xptr);
	scope_demo(14);
	log_info("The value of x outside test_func is : %d", *xptr);

	return 0;
}
int main(int argc, const char *argv[])
{
	log_info("My name: %s, age: %d",MY_NAME,get_age());
	set_age(24);
	log_info("My age is now: %d",get_age());

	log_info("The Size is: %d",THE_SIZE);
	print_size();

	THE_SIZE=9;
	log_info("The Size is now: %d",THE_SIZE);
	print_size();

	log_info("Ratio at first: %f",update_ratio(2.0));
	log_info("Ratio again: %f",update_ratio(10.0));
	log_info("Ratio once more: %f",update_ratio(300.0));

	int count=4;
	scope_demo(count);
	scope_demo(count*20);

	log_info("Count after calling scope_demo: %d",count);
	return 0;

	return 0;
}
Exemple #4
0
int main(int argc, char **argv) {
  log_info("My name is %s, age is %d", MY_NAME, get_age());

  set_age(100);

  log_info("My age is now %d", get_age());

  log_info("THE SIZE is %d", THE_SIZE);
  print_size();

  THE_SIZE = 9;

  log_info("THE SIZE is now %d", THE_SIZE);
  print_size();

  log_info("Ratio at first: %f", update_ratio(2.0));
  log_info("Ratio again: %f", update_ratio(10.0));
  log_info("Ratio once more: %f", update_ratio(300.0));

  int count = 4;
  scope_demo(count);
  scope_demo(count * 20);

  log_info("count after calling scope demo %d", count);

  return 0;
}
int main(int argc, char *argv[])
{
	log_info("my name: %s, age: %d", MY_NAME, get_age());

	set_age(100);

	log_info("my age is now: %d", get_age());

	// test ou thte SIZE_EXTERN
	log_info("THE_SIZE is: %d", THE_SIZE);
	print_size();

	log_info("Ratio at first: %f", *update_ratio(2.0));
	log_info("Ratio again: %f", *update_ratio(10));
	log_info("Ratio once more: %f", *update_ratio(300.0));

	int count = 4;
	scope_demo(count);
	scope_demo(count * 20);

	log_info("count after calling scope_demo: %d", count);

	double *static_ratio = update_ratio(0.5);
	log_info("reaching in to the static ratio: %f", *static_ratio);

	*static_ratio = .001;
	
	log_info("changed the static ration in to the static ratio: %f", *static_ratio);

	return 0;
}
int main()
{
	log_info("My name : %s, age: %d",MY_NAME,get_age());
	
	set_age(100);
	
	log_info("My name now is : %d",get_age());
	
	log_info("THE_SIZE is: %d", THE_SIZE);
	
	print_size();
	
	THE_SIZE = 9;

    log_info("THE SIZE is now: %d", THE_SIZE);
    print_size();
    
    log_info("Ratio at first: %f", update_ratio(2.0));
    log_info("Ratio again: %f", update_ratio(10.0));
    log_info("Ratio once more: %f", update_ratio(300.0));
    
    // test the scope demo
    int count = 4;
    scope_demo(count);
    scope_demo(count * 20);

    log_info("count after calling scope_demo: %d", count);
    
	return 0;
}
int main(int argc, char *argv[])
{
    log_info("my name %s, age %d", MY_NAME, get_age());

    set_age(100);

    log_info("my age is now %d", get_age());
    log_info("THE_SIZE is %d", THE_SIZE);
    print_size();

    THE_SIZE = 9;

    log_info("THE_SIZE is now %d ", THE_SIZE);
    print_size();

    log_info("ratio at first : %f", update_ratio(2.0));
    log_info("ratio now : %f", update_ratio(10.0));
    log_info("ratio finally : %f", update_ratio(300.0));

    int count = 4;
    scope_demo(count);
    scope_demo(count * 20);

    log_info("Count after calling scope_demo : %d", count);

    return 0;
}
Exemple #8
0
int main(int argc, char *argv[])
{
    // test out THE_AGE accessors
    log_info("My name: %s, age: %d", MY_NAME, get_age());

    set_age(100);

    log_info("My age is now: %d", get_age());

    int new_age = 44;
    log_info("Setting age directly to %d", new_age);
    int *age = get_age_pointer();
    *age = new_age;

    log_info("My age is now: %d", get_age());

    // test out THE_SIZE extern
    log_info("THE_SIZE is: %d", THE_SIZE);
    print_size();

    THE_SIZE = 9;

    log_info("THE_SIZE is now: %d", THE_SIZE);
    print_size();

    // test the ratio function static
    log_info("Ratio at first: %f", update_ratio(2.0));
    log_info("Ratio again: %f", update_ratio(10.0));
    log_info("Ratio once more: %f", update_ratio(300.0));

    // accessing a function static
    double *func_static_value = get_function_static(4.0);
    log_info("get_function_static(4.0) = %.1f", *func_static_value);
    double new_func_static_value = 8.0;
    log_info("Setting the function static var directly to %.1f",
            new_func_static_value);
    *func_static_value = new_func_static_value;
    log_info("get_function_static(4.0) = %.1f", *get_function_static(4.0));

    // test the scope demo
    int count = 4;
    scope_demo(count);
    scope_demo(count * 20);

    log_info("count after calling scope_demo: %d", count);

    return 0;
}
Exemple #9
0
int main(int argc, char *argv[])
{
	// test out THE_AGE accessors
	log_info("My names: %s, age: %d", MY_NAME, get_age());

	set_age(100);

	log_info("My age is now: %d", get_age());

	// test out THE_SIZE extern
	log_info("THE_SIZE is: %d", THE_SIZE);
	print_size();

	THE_SIZE = 9;

	log_info("THE_SIZE is now: %d", THE_SIZE);
	print_size();

	// test the ration function static
	log_info("Ratio at first: %f", update_ratio(2.0));
	log_info("Ratio again: %f", update_ratio(10.0));
	log_info("Ratio once more: %f", update_ratio(300.0));

	double *res = update_ratio_ptr(2.0);
	log_info("Ratio by pointer: %f\n", *res);
	*res = 100.0;
	res = update_ratio_ptr(15.0);
	log_info("Ratio by pointer: %f\n", *res);

	// test the scope demo
	int count = 4;
	scope_demo(count);
	scope_demo(count * 20);

	log_info("count after calling scope_demo: %d", count);

	log_info("Recursive result: %llu\n", recursive(100000, 0));

	return 0;
}
Exemple #10
0
int main(int argc, char** argv) {
        log_info("My name is %s and I am %d years old.", MY_NAME, get_age());

        set_age(100);

        log_info("Now I'm older! I'm %d.", get_age());

        log_info("The size is: %d", THE_SIZE);
        print_size();

        THE_SIZE = 9;

        log_info("The size is now: %d", THE_SIZE);
        print_size();

        // test the ratio function static
        log_info("Ratio: %f", *update_ratio(2.0));
        log_info("Ratio: %f", *update_ratio(10.0));
        log_info("Ratio: %f", *update_ratio(300.0));

        double* evil = update_ratio(1.0);

        // H4X. I grabbed a static function variable and am changing its
        // contents here.
        log_info("%f", *evil);
        *evil = 123.0;
        log_info("%f", *evil);
        update_ratio(9);

        // test the scope demo
        int count = 4;
        scope_demo(count);
        scope_demo(count * 20);

        log_info("count after calling scope_demo: %d", count);

        return 0;
}
Exemple #11
0
int main(int argc, char *argv[])
{
	// test out THE_AGE accessors
	log_info("My name: %s, age: %d", MY_NAME, get_age());
	set_age(200);
	log_info("My age is now: %d", get_age());
	// test out THE_SIZE extern
	log_info("THE_SIZE is: %d", THE_SIZE);
	log_info("The address of THE_SIZE is: %p", &THE_SIZE);
	print_size();

	THE_SIZE = 9;

	log_info("The SIZE is now: %d", THE_SIZE);
	print_size();

	// test the ratio function static
	log_info("Ratio at first: %f", update_ratio(2.0));
	log_info("Ratio again: %f", update_ratio(10.0));
	log_info("Ratio once more: %f", update_ratio(300.0));

	// test the scope demo
	int count = 4;
	scope_demo(count);
	scope_demo(count * 20);
/*	
	log_info("count after calling scope_demo: %d", count);
	log_info("The ratio is: %f", ratio);

	log_info("The address of THE_AGE: %p", &get_age());
	log_info("The current value of THE_AGE: %d", get_age());
	*get_age() = 0;
	log_info("After setting THE_AGE pointer to 0 THE_AGE value is: %d", THE_AGE);	
*/
	return 0;
}
Exemple #12
0
void scope_demo(int count) {
  log_info("count is %d", count);

  if (count > 10) {
    int count = 100;

    log_info("count in this scope is %d", count);
  }

  log_info("count at exit is %d", count);

  count = 3000;

  log_info("count after assign is %d", count);

  scope_demo();
}
Exemple #13
0
void scope_demo(int count)
{
    log_info("count is: %d", count);

    if(count > 10) {
        int count = 100;  // BAD! BUGS!

        log_info("count in this scope is %d", count);
    }

    log_info("count is at exit: %d", count);

    count = 3000;

    log_info("count after assign: %d", count);

    scope_demo(count);
}
Exemple #14
0
void scope_demo(int count)
{
  log_info("count is: %d", count);

  if(count > 10) {
    int count = 100; // this is very bad

    log_info("count is this scope is %d", count);
  }

  log_info("count is at exit: %d", count);

  count = 3000;

  log_info("count after assign: %d", count);

  scope_demo(count);
}