Ребята подскажите как в консоли сделать чтобы можно было вводить кучу строк а по окончании ввести 0 и закончить ввод пока я так сделал
| Код | // lr3.cpp : Defines the entry point for the console application.
#include "stdafx.h" #include <iostream> #include <stdio.h> #include <conio.h> using namespace std;
int process (const char* FileName); char buffer[100]; const int bufSize = 255; char in_buff[bufSize]; //int NameIn(char name[20]); char FileName[]="in.txt";
int main(){ FILE *fnPtr=fopen(FileName,"w"); if(fnPtr == NULL) { cout << "File couldnt be open"; } else { cout << "Enter ->";
//Здесь надо цикл сделать а какой не могу понять cin.getline(in_buff, bufSize); fprintf(fnPtr,"%s",in_buff); } fclose(fnPtr); process(FileName); return 0; }
int process (const char* FileName) {
FILE *fnPtr=fopen(FileName,"r"); if(fnPtr == NULL) { cout << "File couldnt be open"; } fgets(buffer,100,fnPtr); cout << buffer; _getch(); return 0; }
|
|