| | |
Interactive text file
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I want to make a program that will start off by opening a text file(blank). The user will put an expression in the file and as he hits the enter(enters a newline character) the result will be shown in the next line of the same open file. Itz almost like replacing the console with a text file. The way mathematica and maple evaluates itz inputs. Is it possible without too much hassle?
I used kbhit() before as i made some small games. I used it inside game loops when u need to read the input only when kbhit() returns a nonzero value(i.e there's been a keyboard hit). I dont know if it can help us with the interactive file thingy. Atleast the following piece of code does not.
C++ Syntax (Toggle Plain Text)
#include<conio.h> #include<iostream> #include<fstream> using namespace std; int main() { ofstream out("out.txt"); out.close(); system("out.txt"); char ch; while(true) { if(kbhit()) { ch = getchar(); cout<<ch; } } }
The program opens a blank text file as it starts. The user writes something on that file. I want to know what the user is typing on that textfile. Since i havent done anything like this before, i dont know what to expect from kbhit() in this regard. Maybe a function that can globally read keyboard inputs is necessary in this case, not something that only works when the console is active. I am not sure kbhit() or getchar() will do that job for me.
Think getch instead of kbhit. An interactive file isn't a file you write directly to with the keyboard. An interactive file is a file that is saved with every change made. You use the console as the middleman between the keyboard and file, but every character you enter is written straight away.
The only difference between, say, vanilla Notepad and Notepad with an interactive file is that vanilla Notepad only saves when you tell it to. Notepad with an interactive file would save constantly so that if power is interrupted and you have to reboot, you don't lose any of your work.
The only difference between, say, vanilla Notepad and Notepad with an interactive file is that vanilla Notepad only saves when you tell it to. Notepad with an interactive file would save constantly so that if power is interrupted and you have to reboot, you don't lose any of your work.
I'm here to prove you wrong.
![]() |
Similar Threads
- connect to text file database (Visual Basic 4 / 5 / 6)
- Store Bluetooth remote address to a text file (C++)
- Read and write to an ASCII Text file (Java)
Other Threads in the C++ Forum
- Previous Thread: Global char returns numbers instead of text
- Next Thread: Two-way class communication
| Thread Tools | Search this Thread |
api array based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






