32 Replies - 1214 Views - Last Post: 02 October 2012 - 07:57 PM
#16
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 03:07 AM
#17
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 03:21 AM
Your instructor should provide you with a manual, it'll ease your pain
#18
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 03:35 AM
Whose instructor? Mine? Well, the internet is good enough for me. And besides, I doubt my instructor himself has seen any manual, let alone TC++'s manual.
#19
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 07:04 AM
Quote
have never seen a Turbo-C++ manual! I also want one! 
Then maybe you'd be interested in this: Borland C++.
But I really suggest you save your money for something useful.
Jim
This post has been edited by jimblumberg: 02 October 2012 - 07:06 AM
#20
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:00 AM
Wow, that package weighs 1 pound!
And no, I'm not even considering buying it. After all this time, you still think I'd be stupid enough to actually buy something even remotely related to TC++?
And no, I'm not even considering buying it. After all this time, you still think I'd be stupid enough to actually buy something even remotely related to TC++?
#21
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:15 AM
Quote
Wow, that package weighs 1 pound!
Only 1 pound, must not contain all the manuals, should be closer to 6 pounds if all the manuals are present.
Quote
After all this time, you still think I'd be stupid enough to actually buy something even remotely related to TC++?
Nope.
Jim
#22
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:18 AM
I still need to know how to get the back space characters into the text file. They appear as little boxes if I send "\b" to the file.
#23
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:22 AM
The backspace character is a non-printing character. How are you determining that this character is not in the file? What do you expect this non-printing character to look? How are you opening the file?
I recommend you post your current code that illustrates your problems.
Jim
I recommend you post your current code that illustrates your problems.
Jim
This post has been edited by jimblumberg: 02 October 2012 - 08:22 AM
#24
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:26 AM
#include <iostream.h>
#include <conio.h>
#include <fstream.h>
int main()
{
char c;
ofstream fout("C:\\USERS\\*****\\DESKTOP\\example.txt");
do
{
c=getch();
int a=c;
if(a==8)
{
cout<<"\b";
fout<<"\b";
}
else
{
fout<<c;
cout<<c;
}
} while(c!='`');
fout.close();
return 0;
}
This is the code that I am trying to run,..
The attached file is the output.
Attached File(s)
-
EXAMPLE.TXT (59bytes)
Number of downloads: 16
#25
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:32 AM
Your example seems to have about 13 backspace characters at the end of your sentence.
Here is a hexdump of your file.
The 0x08 is the proper value for the backspace character.
Jim
Here is a hexdump of your file.
00000000 54 68 65 20 71 75 69 63 6B 20 62 72 6F 77 6E 20 The quick brown 00000010 66 6F 78 20 6A 75 6D 70 65 64 20 6F 76 65 72 20 fox jumped over 00000020 74 68 65 20 6C 61 7A 79 20 64 6F 67 2E 08 08 08 the lazy dog.... 00000030 08 08 08 08 08 08 08 08 08 08 60 ..........`
The 0x08 is the proper value for the backspace character.
Jim
#26
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:35 AM
Yeah, I pressed it 13 times. What I need to do is, to read those characters and remove the last letter entered from the stream. Is that possible?
#27
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:39 AM
The best bet is not to write that character in the first place. What character are you trying to remove?
Jim
Jim
#28
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:46 AM
If the user enters backspace in the screen, I need to remove the last character entered. The characters are being stored in the buffer without the user having to type return, so it goes into the stream. I need to know how to remove those characters before writing it into the file.
#29
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 08:55 AM
What is so wrong about using the normal entry methods? Why is requiring the enter key such a big deal?
If you want to be able to enter the keys using getch() but be able to edit the entry you will need to implement your own buffer. You place the characters into the buffer but you don't write this buffer to the file until you are sure the entry is complete.
Until you are much more familiar with C/C++ I recommend you stick to the standard input output techniques, such as getline(), cin, cout.
Jim
If you want to be able to enter the keys using getch() but be able to edit the entry you will need to implement your own buffer. You place the characters into the buffer but you don't write this buffer to the file until you are sure the entry is complete.
Until you are much more familiar with C/C++ I recommend you stick to the standard input output techniques, such as getline(), cin, cout.
Jim
#30
Re: question: How do I implement a basic CUI in c++?
Posted 02 October 2012 - 09:03 AM
You see, the problem is, I am making a text editor. I need to give an edit option.
|
|

New Topic/Question
Reply





MultiQuote



|