Показать сообщение отдельно

  #960  
Старый 07.04.2008, 22:21
Benzin
Познающий
Регистрация: 15.01.2007
Сообщений: 41
Провел на форуме:
267196

Репутация: 6
По умолчанию

2 horlyk: А чем тебя не устраивает вышеописанный вариант вариант?
Код:
#include <iostream.h>
using namespace std;

int again;
char szInput[256];
  
int main()
{
   for(;;)
   {
     puts ("\n\n\n\nEnter a sentence: ");
     cin>>szInput;
     printf("\n\n\t\tThe sentence entered is %u characters long)\n",strlen(szInput));
     puts("\n\n\t\t\t*** Third task completed ***");
     printf("\n\n\nagain? 1 - yes\n");
     
     cin >> again;    
     if(again!=1)
     break;
   }
   return 0;
}
Только надо добавить:
#include <string.h>
#include <stdio.h>

Ну или хочешь то можно и так:
Код:
#include <iostream.h>
#include <string.h>
#include <stdio.h>

int myfunc();

int again=1;
char szInput[256];
  
int main()
{
	while (again==1)
	{
		myfunc();		
	}

	return 0;
}

int myfunc()
{
	puts ("\n\n\n\nEnter a sentence: ");    
	cin>>szInput;     
	printf("\n\n\t\tThe sentence entered is %u characters long\n",strlen(szInput));     
	puts("\n\n\t\t\t*** Third task completed ***");    
	printf("\n\n\nagain? 1 - yes\n");     
    cin >> again;
	 
    if(again!=1)
	{
		return false;
	}
	return 0;
}
 
Ответить с цитированием