#include <iostream>
#include <fstream>
#include <string>
int main()
{
const std::string stop_string = "stop";
std::string curr_string;
std::ofstream file;
file.open( "log.txt", std::ios::out );
if( file.fail() )
return -1;
std::cin >> curr_string;
for( int i = 1; curr_string != stop_string; ++i )
{
file << i << ")" << curr_string << "\n";
std::cin >> curr_string;
}
//system("pause");
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
const int BUF_SIZE = 64;
const char* stop_string = "stop";
char curr_string[BUF_SIZE];
FILE* file;
file = fopen( "log.txt", "w" );
if( 0 == file )
return -1;
scanf( "%s", curr_string );
for( int i = 1; 0 != strcmp(curr_string, stop_string); ++i )
{
fprintf( file, "%i)%s\n", i, curr_string );
scanf( "%s", curr_string );
}
fclose( file );
//system("pause");
return 0;
}
fprintf( file, "%i)%s\n", i, curr_string );
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.