Пример #1
0
void MYMENU_EditCopy()
{
    if ( editmode == 1 ) {
        SendMessageW( hEdit, WM_COPY, 0, 0 );
    }
    else {
        clear_stream();
        selection2stream( table );
    }
}
Пример #2
0
/* resize the db and add a book struct with user input
 * this lives here since it uses static db functions */
void user_add_book(void)
{
	Book* B;
	long id;
	int year;
	char title[257];
	char name[112];
	char pub[41];

	/* get user input */
	fprintf(stdout, "Title of the Book? ");
	clear_stream();

	if (! fgets(title, sizeof(title) - 1, stdin))
		/* checking for error */
		goto error;
	chomp(title);

	printf("Author? ");
	if (! fgets(name, sizeof(name) - 1, stdin))
		goto error;
	chomp(name);

	printf("ID (10 numbers)? ");
	if (scanf("%ld", &id) == 0)
		goto error;

	/* clearing stream in another way due to scanf */
	while(getchar() != '\n');

	printf("When was it published? ");
	if (scanf("%d", &year) == 0)
		goto error;
	while(getchar() != '\n');

	printf("Publisher company? ");
	if (! fgets(pub, sizeof(pub) - 1, stdin))
		goto error;
	chomp(pub);

	/* create and call function to add it */
	B = create_book(id, title, year, pub);
	split_create_authors(B, name);

	if (!add_book(B)) {
		printf("Book node added to database\n");
		return;
	}

error:
	printf("Book creation aborted\n");
	return;
}