Example #1
0
// main
int main(int argc, char *argv[]) {
  int e;

  if(argc >= 2) {
      e = atoi(argv[1]);
      switch (e) {
        case 11 : {
          example1(argv[2]);
          break;
        }

        case 1 : {
          redirect();
          break;
        }

        case 2 : {
          childRedirect();
          break;
        }

        case 3 : {
          redirectWithWC();
          break;
        }
      }
  } else {
    printf("ERROR: Check the number of arguments\n");
    //example1("exemplo1.txt");
  }

  return 0;
}
Example #2
0
int main(void)
{
   example1();
   example1b();
   example2();
   return 0;
}
Example #3
0
int main(int argc, char *argv[])
{
	example1();
	example2();

	return 0;
}
void main()
{
	int *a1=example1(10);
	int *b1=example2(10);
	printf("%d\n",*a1);
	printf("%d\n",*b1);
}
Example #5
0
int main()
{
    example1();
    printf("-----------------------\n");
    example2();
    return 0;
}
Example #6
0
int main()
{
    example1();
    example2();
    example3();
    example4();

    return 0;
}
Example #7
0
int main(int argc,char* argv[]){
  init_memory(&a[0], &a[N*2]);
  init_memory(&b[0], &b[N*2]);
  init_memory(&c[0], &c[N*2]);
  for (int i=0; i < LOOPA; ++i) 
    example1();

  return 0;
}
Example #8
0
    void nextArgument() const {
        givenACodeSampleToTokenize example1("foo(1, 2, 3, 4);");
        ASSERT_EQUALS(true, Token::simpleMatch(example1.tokens()->tokAt(2)->nextArgument(), "2 , 3"));
        ASSERT_EQUALS(true, Token::simpleMatch(example1.tokens()->tokAt(4)->nextArgument(), "3 , 4"));

        givenACodeSampleToTokenize example2("foo();");
        ASSERT_EQUALS(true, example2.tokens()->tokAt(2)->nextArgument() == 0);

        givenACodeSampleToTokenize example3("foo(bar(a, b), 2, 3);");
        ASSERT_EQUALS(true, Token::simpleMatch(example3.tokens()->tokAt(2)->nextArgument(), "2 , 3"));

        givenACodeSampleToTokenize example4("foo(x.i[1], \"\", 3);");
        ASSERT_EQUALS(true, Token::simpleMatch(example4.tokens()->tokAt(2)->nextArgument(), "\"\" , 3"));
    }
Example #9
0
int main () {
	int semid, shmid;
	unsigned short seminit[NUM_SEMS];
	struct common *shared;
	union semun semctlarg;
	struct customer *first_in_line;

	semid = semget(SEMKEY, NUM_SEMS, 0777 | IPC_CREAT);
	if (semid < 0) {
                perror("Could not get semaphores");
		exit(EXIT_FAILURE);
        }
	seminit[SEM_MUTEX]=1;
	seminit[SEM_WAITLIST]=0;
	semctlarg.array = seminit;
	semctl(semid, NUM_SEMS, SETALL, semctlarg);

	shmid = shmget(SHMKEY, sizeof(struct common), 0777 | IPC_CREAT);
	if (shmid < 0) {
                perror("Could not get shared memory");
       		exit(EXIT_FAILURE);
	 }
	shared=(struct common *)shmat(shmid, 0, 0);
	shared->wait_count = 0;
	shared->balance = 500;

	shmid = shmget(LINESTART, sizeof(struct customer), 0777 | IPC_CREAT);
	if (shmid < 0) {
                perror("Could not get shared memory");
		exit(EXIT_FAILURE);
        }
	first_in_line = (struct customer *)shmat(shmid, 0, 0);

	shared->customer_offset = LINESTART;
	shared->front_of_line = LINESTART;

	example1();
	example2();
	example3();

	semctl(semid, NUM_SEMS, IPC_RMID, 0);
	shmctl(shmid, IPC_RMID, 0);

	return EXIT_SUCCESS;
}
Example #10
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    UICommonFrame frame(new Widget);
    frame.show();


    UICommonFrame example1(new Example_1);
    example1.setTitleBarIcon(":/image/cat.ico");
    example1.show();

//    QFrame w;
//    w.setWindowFlags(Qt::FramelessWindowHint);
//    w.setAttribute(Qt::WA_TranslucentBackground);
//    w.show();
    
    return a.exec();
}
Example #11
0
inline void array_examples()
{
    std::ofstream of("output/output.txt");
    cl::tape_serializer<cl::tvalue> serializer(of);
    serializer.precision(3);

    plus_example(serializer);
    minus_example(serializer);
    exp_example(serializer);
    cos_example(serializer);
    discount_example(serializer);
    example1(serializer);
    sum_example(serializer);
    rev_example(serializer);
    conc_example(serializer);
    make_example(serializer);
    max_example(serializer);
    norm_example(serializer);
    linear_regression_example(serializer);
}
Example #12
0
/*--------------------------------------------------------------------------*/
int main(void)
/* int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow) */
{
    if ( StartScilab(NULL, NULL, NULL) == FALSE ) printf("Error : StartScilab\n");
    printf("\nexample 1\n");
    example1();
    printf("\npress return\n");
    getchar();

    printf("\nexample 2\n");
    example2();
    printf("\npress return\n");
    getchar();

    printf("\nexample 3\n");
    example3();
    printf("\npress return\n");
    getchar();


    if ( TerminateScilab(NULL) == FALSE ) printf("Error : TerminateScilab\n");
    return 0;
}
Example #13
0
int main(int argc, char **argv)
{
	int num;
	int i;
	char retval = 0;
	u_error_t *error = NULL;
	u_option_entry_t opt[] = {
		{"debug", 'd', U_OPTION_ARG_INT, &debug_level,
		 "Set the verbosity of debugging output.", "1-6"}
	};
	u_option_context_t *opt_ctx;
	opt_ctx = u_option_context_new("");
	u_option_context_set_ignore_unknown_options(opt_ctx, FALSE);
	u_option_context_add_main_entries(opt_ctx, opt, "wsmid_identify");
	retval = u_option_context_parse(opt_ctx, &argc, &argv, &error);

	u_option_context_free(opt_ctx);

	if (error) {
		if (error->message)
			printf("%s\n", error->message);
		u_error_free(error);
		return 1;
	}
	u_error_free(error);

	if (debug_level) {
		initialize_logging();
		wsman_debug_set_level(debug_level);
	}

	if (argc == 1) {
		// execute all
		example1();
		example2();
		example3();
		example4();
		example5();
		example6();
		example7();
		example8();
		example9();
		example10();
		example11();
		example12();
		example13();
		example14();
		return 0;
	}

	for (i = 1; i < argc; i++) {
		num = atoi(argv[i]);
		switch (num) {
		case 1:
			example1();
			break;
		case 2:
			example2();
			break;
		case 3:
			example3();
			break;
		case 4:
			example4();
			break;
	        case 5: 
			example5(); 
			break;
		case 6:
			example6();
			break;
		case 7:
			example7();
			break;
		case 8:
			example8();
			break;
		case 9:
			example9();
			break;
		case 10:
			example10();
			break;
		case 11:
			example11();
			break;
		case 12:
			example12();
			break;
		case 13:
			example13();
			break;
		case 14:
			example14();
			break;
		default:
			printf("\n    No example%d()\n", num);
			break;
		}
	}
	return 0;
}
Example #14
0
// Dialog proc for the Windows window
int CALLBACK DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_INITDIALOG:
			hDlg = hWnd;
			break;

		case WM_CLOSE:
			EndDialog(hWnd, 0);
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			break;

		case WM_COMMAND:
		{
			if (HIWORD(wParam) != BN_CLICKED)
				break;

			SetWindowText(GetDlgItem(hWnd, IDC_OUTPUT), L"");

			switch (LOWORD(wParam))
			{
				case IDC_VERIFY:
				case IDC_ECHO:
				{
					int size = GetWindowTextLength(GetDlgItem(hWnd, IDC_INPUT));
					wchar_t* text = new wchar_t[size + 1];
					GetWindowText(GetDlgItem(hWnd, IDC_INPUT), text, size + 1);

					JSONValue *value = JSON::Parse(text);

					if (value == NULL)
					{
						SetWindowText(GetDlgItem(hWnd, IDC_OUTPUT), L"The JSON text *is not* valid");
					}
					else
					{
						if (LOWORD(wParam) == IDC_ECHO)
							SetWindowText(GetDlgItem(hWnd, IDC_OUTPUT), value->Stringify().c_str());
						else
							SetWindowText(GetDlgItem(hWnd, IDC_OUTPUT), L"The JSON text *is* valid");
						delete value;
					}

					delete text;
					break;
				}

				case IDC_EX1:
					extern const wchar_t *EXAMPLE;
					SetWindowText(GetDlgItem(hDlg, IDC_INPUT), EXAMPLE);
					example1();
					break;

				case IDC_EX2:
					SetWindowText(GetDlgItem(hDlg, IDC_INPUT), L"Example 2:\r\n\r\nKey 'test_string' has a value 'hello world'\r\nKey 'sample_array' is an array of 10 random numbers");
					example2();
					break;

				case IDC_TESTCASES:
					SetWindowText(GetDlgItem(hWnd, IDC_INPUT), L"");
					run_tests();
					break;
			}

			break;
		}
	}

	return 0;
}
Example #15
0
void example1() {
	example1(true);
	example1(false);
}
Example #16
0
File: main.cpp Project: klusark/sat
int main() {
	std::cout << "*** Running example1 ***" << std::endl;
	example1();
	std::cout << "*** Running example2 ***" << std::endl;
	example2();
}