int main() {
	char* words = console_read_line(100, 1000);
	char** words_split = NULL;
	int split_len = str_split(&words_split, words, ", ");
	char* text = console_read_line(100, 1000);
	text = filter_text(text, words_split, split_len, '*');

	printf("\n%s\n", text);

	if (words_split) free_str_arr(words_split, split_len);
	if (words) free(words);
	if (text) free(text);
	return 0;
}
int main() {
	char* line = console_read_line(100, 1000);
	str_reverse(line);
	printf("%s\n", line);
	free(line);
	return 0;
}
Пример #3
0
int main() {
    uart_init(9600);

    char uart_buffer[255];

    uprintf("StarDrive Monitor 0.01\nCopyright 2011 Evan Zalys\n");
    help();

    while(1) {
        int i, chrs;
        char *argv[16];
        int argc;

        uprintf(PROMPT);

        chrs = console_read_line(uart_buffer);
        if(chrs == 0) {
            continue;
        }

        argc = console_tokenize_args(uart_buffer, argv);

        if(strcmp(argv[0], "help") == 0)
            help();
        else if(strcmp(argv[0], "shelltest") == 0)
            shelltest(argc, argv);
        else
            uprintf("Unrecognized command\n");
    }
}
int main() {
	char* line = console_read_line(21, 21);
	add_asterix(line);
	printf("%s\n", line);
	free(line);
	return 0;
}
Пример #5
0
int main()
{
    char input_line[256];
    int got;

    console_init(init_vga(VGA_MODE_640x480), 640, 480);
    console_set_colors(WHITE, BLACK);
    console_puts("\n !\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_`{|}~\n");
    console_puts(" ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
    console_puts(" abcdefghijklmnopqrstuvwxyz\n");
    console_puts(" AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\n");
    console_puts(" The quick brown fox jumped over the lazy dog.\n");
    console_set_colors(BLACK, WHITE);
    console_puts(" Inverse text\n");
    console_set_colors(WHITE, BLACK);
    while (1)
    {
        console_puts("> ");
        got = console_read_line(input_line, sizeof(input_line));
        input_line[got] = '\0';
        printf("%s\n", input_line);
    }

    return 0;
}
int main() {
	printf("str = ");
    char* str = console_read_line(20, 100);
    printf("reverse = %s\n", r_reverse(str, strlen(str), 0));
	free(str);
	return 0;
}
int main() {
	char* line = console_read_line(100, 1000);
	char* removed_series = remove_letter_series(line);
	
	if (removed_series) printf("%s\n", removed_series);
	if (line) free(line);
	if (removed_series) free(removed_series);
	return 0;
}
int main() {
	char* line, ch;
	printf("text = ");
	line = console_read_line(50, 200);
	printf("ch = ");
	scanf("%c", &ch);

	int last_occurence = last_occurence_of_char(line, strlen(line), ch);
	printf("%d\n", last_occurence);

	free(line);
	return 0;
}
int main()
{
	int n;
	if (!read_int(&n))
		return 1;

	char** str_arr = malloc(n * sizeof(char*));
	for (int i = 0; i < n; ++i) {
		str_arr[i] = console_read_line(20, 200);
	}

	selection_sort(str_arr, n, sizeof(char*), string_coparator);

	printf("\n");
	for (int i = 0; i < n; ++i) {
		printf("%s\n", str_arr[i]);
	}

	str_arr_free(str_arr, n);
	return 0;
}
int main(int argc, char const *argv[])
{
	char* line;
	line = console_read_line(10, 100);

	int i = 0;

	while(i >= 0) {
		if (line[i] == '\0') {
			printf("'\\0'\n");
			break;
		}

		printf("%c ", line[i]);
		i++;
	}


	printf("\n");
	free(line);
	return 0;
}
int main () {
	char* line = console_read_line(20, 500);
	int line_size = strlen(line);
	bool time_is_pm = false;

	if (line == NULL) {
		printf("Console read error\n");
		return 1;
	}

	if (line[line_size - 2] == 'P' &&
		line[line_size - 1] == 'M') {
	
		time_is_pm = true;
	} else if (line[line_size - 2] == 'A' &&
			   line[line_size - 1] == 'M') {

		time_is_pm = false;
	} else {
		printf("Invalid time\n");
		return 1;
	}

	bool in_hour = true;
	int i, hour = 0, min = 0;
	for (i = 0; i < line_size; ++i) {
		if (line[i] == ':') {
			in_hour = false;
			continue;
		}

		if (in_hour && isdigit(line[i])) {
			if (hour == 0)
				hour = line[i] - '0';
			else 
				hour = hour * 10 + (line[i] - '0');

			if (hour < 0 || hour > 12) {
				printf("Invalid time\n");
				return 1;
			}
		} else if (isdigit(line[i])) {
			if (min == 0)
				min = line[i] - '0';
			else
				min = min * 10 + (line[i] - '0');

			if (min < 0 || min > 60) {
				printf("Invalid time\n");
				return 1;
			}
		} else {
			break;
		}
	}
		
	bool beer_time = false;
	if (time_is_pm) {
		if (hour > 0) {
			beer_time = true;
		}
	} else {
		if (hour < 3) {
			beer_time = true;
		}
	}
		
	printf("%s", beer_time == true ? "beer time": "non-beer time");
	if (line != NULL)
		free(line);
	return 0;
}