Ejemplo n.º 1
0
int main()
{
	char s[SMAXLENGTH];
	char t[TMAXLENGTH];
	gettxt(s, SMAXLENGTH);
	escape(s, t);
	printf("\ns:\n");
	printarray(s, TMAXLENGTH);
	printf("\nt:\n");
	printarray(t, TMAXLENGTH);
	printf("\n\n");
	return 0;
}
Ejemplo n.º 2
0
main()
{
  register int ch;
  register char ateof;
  register int i;
  register int errorcount;


  init();
  errorcount = 0;
  ateof = FALSE;

  ch = getchar();
  if (ch == EOF)
    exit(0);

  if (ch == EOL)
    {
      cc = NUL;
      ungetc((int) EOL, stdin);
    }
  else if (ch == BLANK)
    cc = NUL;
  else if (ch == '1')
    cc = FF;
  else if (ch == '0')
    cc = EOL;
  else if (ch == '+')
    cc = CR;
  else
    {
      errorcount = 1;
      cc = NUL;
      ungetc(ch, stdin);
    }

  while ( ! ateof)
    {
      gettxt();
      ch = getchar();
      if (ch == EOF)
	{
	  flush();
	  ateof = TRUE;
	}
      else if (ch == EOL)
	{
	  flush();
	  cc = NUL;
	  ungetc((int) EOL, stdin);
	}
      else if (ch == BLANK)
	{
	  flush();
	  cc = NUL;
	}
      else if (ch == '1')
	{
	  flush();
	  cc = FF;
	}
      else if (ch == '0')
	{
	  flush();
	  cc = EOL;
	}
      else if (ch == '+')
	{
	  for (i = 0; i < length; i++)
	    savech(i);
	}
      else
	{
	  errorcount++;
	  flush();
	  cc = NUL;
	  ungetc(ch, stdin);
	}
    }

  if (errorcount == 1)
    fprintf(stderr, "Illegal carriage control - 1 line.\n");
  else if (errorcount > 1)
    fprintf(stderr, "Illegal carriage control - %d lines.\n", errorcount);

  exit(0);
}
Ejemplo n.º 3
0
int main()
{
	char **txt1 = NULL, **txt2 = NULL;
	short isprogend = 0, istxt1 = 0, istxt2 = 0, strct;

	SetConsoleCP(1251);
	SetConsoleOutputCP(1251);
	system("title = Курсовая работа. Обработка текста");

	do
	{
		system("cls");
		switch (menu())
		{
		case '1': //ввод текста
			if (txt1 != NULL)
				txt1 = (char**)dsfree((void**)txt1, strct);
			if (txt2 != NULL)
				txt2 = (char**)(dsfree((void**)txt2, strct));
			istxt1 = 1;
			istxt2 = 0;
			system("cls");
			rewind(stdin);
			txt1 = gettxt(&strct);
			printf_s("\nВвод завершен!\n");
			waitforenter();
			break;
		case '2': //вывод исходного текста
			system("cls");
			if (istxt1)
			{
					printf_s("Исходный текст:\n");
					putstrings(txt1, strct);
			}
			else
				printf_s("Ошибка! Сначала введите исходный текст");
			printf_s("\n");
			waitforenter();
			break;
		case '3': //обработка исходного текста
			system("cls");
			if (istxt1)
			{
				if (txt2 == NULL)
				{
					istxt2 = 1;
					txt2 = wordproc(txt1, strct);
					printf_s("Текст обработан");
				}
				else
					printf_s("Текст уже был обработан");
			}
			else
				printf_s("Ошибка! Сначала введите исходный текст");
			printf_s("\n");
			waitforenter();
			break;
		case '4': //вывод текста
			system("cls");
			if (istxt2)
			{
				printf_s("Результирующий текст:\n");
				putstrings(txt2, strct);
			}
			else
				printf_s("Ошибка! Сначала обработайте исходный текст");
			printf_s("\n");
			waitforenter();
			break;
		case '5': //справка
			system("cls");
			reference();
			printf_s("\n");
			waitforenter();
			break;
		case '6': //выход
			system("cls");
			printf_s("Вы уверены, что хотите выйти?(1-Да/0-Нет): ");
			scanf_s("%hi", &isprogend);
			rewind(stdin);
			break;
		default:
			printf_s("Ошибка! Введите существующий пункт меню\n");
			waitforenter();
		}
	} while (!isprogend);
	if (txt1 != NULL)
		txt1 = (char**)dsfree((void**)txt1, strct);
	if (txt1 != NULL)
		txt1 = (char**)dsfree((void**)txt1, strct);
	return 0;
}