چگونه میتوان آنچه روی صفحه کنسول هست را در سی پلاس پلاس، داخل یک متغیر ذخیره کرد؟؟
سلام..
من میخواستم یه برنامه شبیه به نود پد بنویسم که بتونه در ضمن نوشتن متن توسط کاربر، با زدن کلید اینتر و ... شبیه به نود پد عمل کنه..
اما در هنگام ذخیره فایل نهایی به مشکل برخوردم.. نمیتونم اونچه که رو صفحه نمایش میده رو ذخیره کنم..
مشکلم فقط ریختن متن توی متغیره.. و در آخر استفاده از تابع ofstream برای ذخیره سازی..
برنامه مشکل داره ولی کدشو میزارم که فقط شما بدونید چه خبره..
اینم چیزی که نوشتم..
#include <iostream> #include <fstream> #include <conio.h> #include <windows.h> #include <string.h> using namespace std; void gotoxy(int x, int y); void switcher(); void makan_nama(); void writing(); class fileManager{ private: char inputFile[51]; char outputFile[51]; char str[1]; public: void inFile(){ gotoxy(0,19); cout << "inter the name of input file: "; cin >> inputFile; ifstream ifile(inputFile); ifile >> str; while (str){ cout << str; } } void outFile(){ gotoxy(0,20); cout << "inter the name of output file to save all data: "; cin >> outputFile; ofstream ofile(outputFile); } }; int x,y; string a; string b; int main () { switcher(); } void gotoxy(int x, int y) { HANDLE hConsoleOutput; COORD dwCursorPosition; cout.flush(); dwCursorPosition.X=x; dwCursorPosition.Y=y; hConsoleOutput=GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hConsoleOutput, dwCursorPosition); } void switcher(){ while (1){ a=getch(); switch (a){ case 13: gotoxy (0,y+1); break; default :writing(); } } } void inter(){ if (s==13) gotoxy(0,y+1); } void writing(){ strcat(b,a); }