Esempio n. 1
0
void inits() {
	X a( 12 ); // direct init
	X b = 12; // copy init
	func1( 12 ); // ==>ERROR (often not diagnosed by comiler): copy init of formal argument
	func2( a ); // no copy: direct initialization of a temporary X, and binding a reference
	a = b; // ==>ERROR: copy assignment
	a = 12; // ==>ERROR: implicit conversion: direct init of temp, assignment, destruction of temp
	a = X(12); // ==>ERROR: explicit conversion: same result
	X c = func3(); // ==>ERROR: copy initialization of c
	X d( func3() ); // ==>ERROR: copy initialization of d
	a = func3(); // ==>ERROR: copy init of temporary and assignment to a
	X e = func4(); // ==>ERROR (often not diagnosed by compiler): copy initialization of e
	X f( func4() ); // direct initialization of f
}
Esempio n. 2
0
int main()
{
  const char *libname = "change-loc-2.sl";
  void *h;
  int (*p_func) (int);

  func (3);

  func4 ();

  marker ();

  h = dlopen (libname, RTLD_LAZY);
  if (h == NULL) return 1;

  p_func = dlsym (h, "func2");
  if (p_func == NULL) return 2;

  (*p_func) (4);

  marker ();

  dlclose (h);

  marker ();
  return 0;
}
Esempio n. 3
0
void phase_4(String input)
{
	int arr[2]; //make array to hold our 2 ints
	int i1 = arr[0]; //first input
	int i2 = arr[1]; //second input
	int a = sscanf(input, "%d, %d", i1, i2); // x/s 0x4028f5 --> %d %d" in phase_4

	if(i1 <= 14) //checks 1st int
	{
		int a = func4(i1, 0, 14); //recursion. must = 4 to be valid
		if(a != 4 || i2 != 4)
		{
			explode_bomb();

		}else
		{
			return;
		}

	}
	else
	{
		explode_bomb();
	}
	
}
Esempio n. 4
0
int main()
{
	{
		int v1 = boost::bind(sub, 1, 2)();
		int v2 = boost::bind(sub, _1, 2)(1);
		int v3 = boost::bind(subptr, _1, _2)(1, 2);
		int v4 = boost::bind(&demo::sub, ra, _1, 2)(1);
		int v5 = boost::bind<int>(functor(), _1, 2)(1);
		int v6 = boost::bind(functor(), _1, 2)(1);

		std::cout << v1 << std::endl;
		std::cout << v2 << std::endl;
		std::cout << v3 << std::endl;
		std::cout << v4 << std::endl;
		std::cout << v5 << std::endl;
	}

	{
		boost::function<int(int, int)> func1 = sub;
		boost::function<int(int, int)> func2 = subptr;
		boost::function<int(int, int)> func3 = functor();
		boost::function<int(int, int)> func4 = boost::bind(&demo::sub, a, _1, _2);

		std::cout << func1(1, 2) << std::endl;
		std::cout << func2(1, 2) << std::endl;
		std::cout << func3(1, 2) << std::endl;
		std::cout << func4(1, 2) << std::endl;
	}
}
void
bar (int i)
{
  switch (i)
    {
    default:
      func0 ();
      break;
    case 1:
      func1 ();
      break;
    case 2:
      func2 ();
      break;
    case 3:
      func3 ();
      break;
    case 4:
      func4 ();
      break;
    case 5:
      func5 ();
      break;
    }
}
Esempio n. 6
0
int main() {
  func1(1);
  func2(1, 2);
  func3(1, 2, 3);
  func4(1.0);

  return 0;
}
Esempio n. 7
0
int main()
{
  func1();
  func2();
  func3();
  func4();
  return 0;
}
Esempio n. 8
0
int func5(int f, int d)
{
  int i = 0;
  char *random = "random";
  i=i+f;

  func4(i);
  return i;
}
Esempio n. 9
0
int main()
{
	printf ("%s:%s()\n", __FILE__, __FUNCTION__);
	func1();
	func2();
	func3();
	func4();
	return 0;
};
Esempio n. 10
0
static double func4_6(const double x[], const int iResponse)
{
    if (iResponse == 0)
        return func4(x, iResponse);
    else  if (iResponse == 1)
        return func6(x, iResponse);
    else
        error("bad iResponse");
    return 0;
}
Esempio n. 11
0
int func4(int i1, int zero, int fourteen)
{
	/*

	my attempt to explain func4. I do not know
	how, but parsing 2 into here as $i1 results in the 
	value the program wants (4). using other values
	does not seem to make any sort of pattern evident
	*/

	int counter = 0;

	/*
	some arithmetic
	carried out on
	1st integer, 
	I did not make note of any sort of pattern,
	other than the fact that the number
	14 was essentially halved (integer division)
	4 times to get a correct answer,

	*/
	


	if(i1 == /* some value */)
	{
		i1 = func4(i1, 0, 14);
		counter++;
	}

	if(i1 = /* some other value*/)
	{
		i1 = func4(i1, 0 14);
		counter++;
	}

	return i1;

}
int main(void)
{
    int (*a)[50] = &ReturnC();
    for (const auto i : *a)
        std::cout << i << " "; // 1, 0, 0, ....
    std::cout << std::endl;

    // the same as above.
    for (const auto i: *(func4(4)))
        std::cout << i << " ";
    std::cout << std::endl;

}
Esempio n. 13
0
int main ()
{
  int i[10], r;

  i[0] = 0;
  r = func0(0);
  if (i[0])
    link_error0();

  i[1] = 0;
  r = func1(0);
  if (i[1])
    link_error1();

  i[2] = 0;
  r = func2(0);
  if (i[2])
    link_error2();

  i[3] = 0;
  r = func3(0);
  if (i[3])
    link_error3();

  i[4] = 0;
  r = func4(0);
  if (i[4])
    link_error4();

  i[5] = 0;
  r = func5(0);
  if (i[5])
    link_error5();

  i[6] = 0;
  r = func6(0);
  if (i[6])
    link_error6();

  i[7] = 0;
  r = func7(0);
  if (i[7])
    link_error7();

  return r;
}
Esempio n. 14
0
File: 1_func.c Progetto: janekey/c
int main71()
{
	//函数定义在main函数之后的,需要在main函数开头进行声明
	void func1();
	void func2(float,float);//声明可不写形参
	void func3(int a[]);
	void func4(int a[][3], int n);

	func1();

	int a[2] = {1,2};
	func3(a);
	printf("\n");

	int b[3][3] = {{3,4,4},{6,7,5},{4,2}};
	func4(b, 3);

	return 0;
}
Esempio n. 15
0
		word_t one_calc(const word_t& a, const word_t& b, const word_t& c, const word_t& d,
			unsigned int k, unsigned int s, unsigned int i, unsigned int f)
		{
			word_t f_result;
			switch(f)
			{
				case 0: f_result = func1(b,c,d); break;
				case 1: f_result = func2(b,c,d); break;
				case 2: f_result = func3(b,c,d); break;
				case 3: f_result = func4(b,c,d); break;
			}
			
			word_t aa = a + f_result + proc_buffer[k] + get_sine_table_value(i);

			aa = circular_shift(aa, s);

			aa += b;

			return b + circular_shift(a + f_result + proc_buffer[k] + get_sine_table_value(i), s);
		}
Esempio n. 16
0
int main()
{
    HMODULE lib1;
    HMODULE lib2;

    /* same as rebased test */
    lib1 = myload("win32.multisec.dll.dll");
    lib2 = myload("win32m~1.dll");
    if (lib1 == lib2) {
        print("there is a problem - should have collided, maybe missing\n");
    }

    f();
    func3();
    func4();

    FreeLibrary(lib1);
    FreeLibrary(lib2);

    return 0;
}
Esempio n. 17
0
int main(int argc, char** argv)
{
    int line; char* file;
    int retVal;
    
    func1();
    func2();
    func3();
    func4();
    func5();
    
    
    retVal = GetFirstFTEError(&line, &file);
    while (retVal)
    {
	printf("Error at %s (%d)\n", file, line);		
	retVal = GetNextFTEError(&line, &file);
    }
    
    UntrackFTEErrors();
}
Esempio n. 18
0
File: main.cpp Progetto: CCJY/coliru
int main() {
  int array[] = {42};
  std::vector<int> array2;
  array2.push_back(42);

  // Base function
  func(0, array);
  double a = 3.;
  double b = 4.;
  func(1, array, &a);
  func(2, array,NULL, &b);
  func(3, array, &a, &b);

  // "Convenience" functor
  func_functor<> func2;
  func2(4, array2);

  func_functor<std::list<double> > func3;
  std::list<double> a_list;
  a_list.push_back(5.);
  func3(5, array2, &a_list);

  func_functor<std::vector<double>, std::list<double> > func4;
  std::vector<double> a_vec;
  a_vec.push_back(6.);
  func4(6, array2, &a_vec, &a_list);

  // Convenience functor-function!
  make_func(a_list, empty_parameter())(7, array2, &a_list);

  make_func(empty_parameter(), a_list)(8, array2, NULL, &a_list);

  make_func(a_vec, a_list)(9, array2, &a_vec, &a_list);

  return 0;
}
Esempio n. 19
0
void
func2 (int x)
{
  func4 ();
}
Esempio n. 20
0
int f4() {
  extern int var5, func4();
  return var5 + func4();
}
Esempio n. 21
0
void filter(int *array, int X, int Y, int Z, int * seed, int N, FILE *ofp){
	long long func_start = get_time();
	double xr = round(Y/2.0);
	double yr = round(X/2.0);
	
	int radius = 5;
	int diameter = radius*2-1;
	int *radiusMatrix = (int *)malloc(diameter*diameter*sizeof(int));
	fillMatrix(radiusMatrix, radius);
	
	int Ones = 0;
	int x, y;
	for(x = 0; x < diameter; x++){
		for(y = 0; y < diameter; y++){
			if(radiusMatrix[x*diameter + y] == 1)
				Ones++;
		}
	}

	double * objxy = (double *)malloc(Ones*2*sizeof(double));
	getNeighbors(radiusMatrix, Ones, objxy, radius);
	
	double *weights = (double *)malloc(sizeof(double)*N);
	double *arrayX = (double *)malloc(sizeof(double)*N);
	double *arrayY = (double *)malloc(sizeof(double)*N);
	
	func0(weights, arrayX, arrayY, xr, yr, N);

	double * probability = (double *)malloc(sizeof(double)*N);
	double * x_j = (double *)malloc(sizeof(double)*N);
	double * y_j = (double *)malloc(sizeof(double)*N);
	double * cfd = (double *)malloc(sizeof(double)*N);
	double * u = (double *)malloc(sizeof(double)*N);
	int * index = (int*)malloc(sizeof(int)*Ones*N);
	
	int i, j;
	for(i = 1; i < Z; i++) {
		func1(seed, array, arrayX, arrayY, probability, objxy, index, Ones, i, X, Y, Z, N);

		func2(weights, probability, N);
		
		double x_e = 0;
		double y_e = 0;

		func3(arrayX, arrayY, weights, &x_e, &y_e, N);
		fprintf(ofp, "%f\n", x_e);
		fprintf(ofp, "%f\n", y_e);
		
		cfd[0] = weights[0];
		for(j = 1; j < N; j++){
			cfd[j] = weights[j] + cfd[j-1];
		}
		double u1 = (1/((double)(N)))*rand1(seed, 0);
		
		func4(u, u1, N);

		func5(x_j, y_j, arrayX, arrayY, weights, cfd, u, N);
	}

	long long func_end = get_time();
	printf("FUNC TIME : %f\n", elapsed_time(func_start, func_end));
	//fflush();

	for(i=0; i<Ones*2; i++) {
		fprintf(ofp, "%f\n", objxy[i]);
	}
	for(i=0; i<N; i++) {
		fprintf(ofp, "%f %f %f %f %f %f %f %f\n", 
			weights[i], arrayX[i], arrayY[i],
			probability[i], x_j[i], y_j[i],
			cfd[i], u[i]);
	}
	for(i=0; i<Ones*N; i++) {
		fprintf(ofp, "%d\n", index[i]);
	}
   		 
	free(radiusMatrix);
	free(objxy);
	free(weights);
	free(probability);
	free(x_j);
	free(y_j);
	free(arrayX);
	free(arrayY);
	free(cfd);
	free(u);
	free(index);    
}
Esempio n. 22
0
int main(int argc, char* argv[]) {

	int a = 10;
	{
	for(int idx = 0; idx < a; idx++) {
		printf("7: idx=%d\n", idx);
	}
	for(int idx = 0; idx < a; idx++) {
		idx++;
		printf("8: idx=%d\n", idx);
	}
	for(int idx=a; idx>=0; --idx) {
		printf("9: idx=%d\n", idx);
	}

	for(int idx=N; idx>0; idx--) {
		printf("10: idx=%d\n", idx);
	}

	for(int idx=a; N>0; N--) {
		printf("11: idx=%d\n", a);
	}

	for(a=15;a>=0;a-=3) {
		printf("12: a=%d\n", a);
	}

	for(a=1;a<15;a+=3) {
		printf("13: a=%d\n", a);
	}
	}

	// example of loop with a complex condition expression
	// in this case the loop is rewritten as a while loop
	for(a=1;a < 10 && a > 0; a+=2) {
		printf("14: a=%d\n", a);
	}

	// example of for loop with missing increment expression
	for(a=0; a!=0; ) {
		printf("15: a=%d\n", a);
	}

	printf("16: a=%d\n", a);

    {
        int end = 20;
        int count;

        for(a=0; a < end; a++) {
                if(a > 10)
                        break;
        }

        count = a;

        printf("17: count = %d\n", count);

        for(a=end; a > 0 ; a--) {
                if(a < 10)
                        break;
        }
        printf("18: a = %d\n", a);
    }

	func(a);
	func2();
	func3();
	func4();
	func5(a);
	func6();
    func7();
}
Esempio n. 23
0
void
func4_fdf (double x, void * p, double *y, double *yprime)
{
  *y = func4 (x, p);
  *yprime = exp (-x) - x * exp (-x);
}
Esempio n. 24
0
int main ()
{
  struct1.val = 1;
  struct2.val = 2;
  ptr1 = &struct1;
  ptr2 = &struct2;
  marker1 ();
  func1 ();
  for (count = 0; count < 4; count++) {
    ival1 = count;
    ival3 = count; ival4 = count;
  }
  ival1 = count; /* Outside loop */
  ival2 = count;
  ival3 = count; ival4 = count;
  marker2 ();
  if (doread)
    {
      static char msg[] = "type stuff for buf now:";
      write (1, msg, sizeof (msg) - 1);
      read (0, &buf[0], 5);
    }
  marker4 ();

  /* We have a watchpoint on ptr1->val.  It should be triggered if
     ptr1's value changes.  */
  ptr1 = ptr2;

  /* This should not trigger the watchpoint.  If it does, then we
     used the wrong value chain to re-insert the watchpoints or we
     are not evaluating the watchpoint expression correctly.  */
  struct1.val = 5;
  marker5 ();

  /* We have a watchpoint on ptr1->val.  It should be triggered if
     ptr1's value changes.  */
  ptr1 = ptr2;

  /* This should not trigger the watchpoint.  If it does, then we
     used the wrong value chain to re-insert the watchpoints or we
     are not evaluating the watchpoint expression correctly.  */
  struct1.val = 5;
  marker5 ();

  /* We're going to watch locals of func2, to see that out-of-scope
     watchpoints are detected and properly deleted.
     */
  marker6 ();

  /* This invocation is used for watches of a single
     local variable. */
  func2 ();

  /* This invocation is used for watches of an expression
     involving a local variable. */
  func2 ();

  /* This invocation is used for watches of a static
     (non-stack-based) local variable. */
  func2 ();

  /* This invocation is used for watches of a local variable
     when recursion happens.
     */
  marker6 ();
  recurser (2);

  marker6 ();

  func3 ();

  func4 ();

  return 0;
} /* end of main */
Esempio n. 25
0
void func5()
{
	for(int i=0 ; i<5 ; i++)
		func4() ;
}
Esempio n. 26
0
namespace CPP14LanguageFeatures
{
    // `decltype(auto)`
    //
    //    * `auto` will always deduce a non-reference type.
    //
    //    * `auto&&` will always deduce a reference type.
    //
    //    * `decltype(auto)` deduces a non-reference or
    //      reference type depending upon the value category
    //      and the nature of a particular expression.
    //

    auto func3()
    {
        static std::string test{"bye!"};

        auto& result(test);
        return result;
    }

    static_assert(std::is_same<decltype(func3()), std::string>(), "");



    decltype(auto) func4()
    {
        static std::string test{"bye again!"};

        auto& result(test);
        return result;
    }

    static_assert(std::is_same<decltype(func4()), std::string&>(), "");



    decltype(auto) func5()
    {
        std::string test{"bye one more time!"};
        return std::move(test);

        // By the way, do not `std::move` things out
        // of a function.
        // This actually returns a reference to a
        // local object, which is not right!
        // Rely on the compiler's RVO, instead.
    }

    static_assert(std::is_same<decltype(func5()), std::string&&>(), "");



    // If you want to know more about type deduction
    // in the latest standard, check out this
    // C++Now 2015 talk by David Stone:

    // "Type Deduction in C++14"

    // All slides from the conference are available here:
    // https://github.com/boostcon/cppnow_presentations_2015/
}
Esempio n. 27
0
int main(int argc, const char *argv[]) {
  func();
  func2();
  func3();
  func4();
}
void
func4_fdf (float x, void * p, float *y, float *yprime)
{
  *y = func4 (x, p);
  *yprime = exp (-x) - x * exp (-x);
}
Esempio n. 29
0
void func3() {
	func4();

	return;
}
Esempio n. 30
0
    // 0048DAA0
void func1(unsigned char *id, int idlen, enctype1_data *cryptkey) {
    if(id && idlen) func4(id, idlen, cryptkey);
}