question: How do I implement a basic CUI in c++?

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

32 Replies - 3719 Views - Last Post: 02 October 2012 - 07:57 PM Rate Topic: -----

#16 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1686
  • View blog
  • Posts: 3,206
  • Joined: 30-May 10

Re: question: How do I implement a basic CUI in c++?

Posted 02 October 2012 - 03:07 AM

Cool - I've found the TurboC manual online How to use the 'T' :wheelchair:
Was This Post Helpful? 0
  • +
  • -

#17 joshua201  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 05-September 07

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
Was This Post Helpful? 0
  • +
  • -

#18 aresh  Icon User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,174
  • Joined: 08-January 12

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.
Was This Post Helpful? 0
  • +
  • -

#19 jimblumberg  Icon User is online

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,681
  • Joined: 25-December 09

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! :cry2:

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

Was This Post Helpful? 0
  • +
  • -

#20 aresh  Icon User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,174
  • Joined: 08-January 12

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++? :o
Was This Post Helpful? 0
  • +
  • -

#21 jimblumberg  Icon User is online

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,681
  • Joined: 25-December 09

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
Was This Post Helpful? 0
  • +
  • -

#22 booleanbalaji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 28-September 12

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.
Was This Post Helpful? 0
  • +
  • -

#23 jimblumberg  Icon User is online

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,681
  • Joined: 25-December 09

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

This post has been edited by jimblumberg: 02 October 2012 - 08:22 AM

Was This Post Helpful? 0
  • +
  • -

#24 booleanbalaji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 28-September 12

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)


Was This Post Helpful? 0
  • +
  • -

#25 jimblumberg  Icon User is online

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,681
  • Joined: 25-December 09

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.
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
Was This Post Helpful? 0
  • +
  • -

#26 booleanbalaji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 28-September 12

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?
Was This Post Helpful? 0
  • +
  • -

#27 jimblumberg  Icon User is online

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,681
  • Joined: 25-December 09

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
Was This Post Helpful? 0
  • +
  • -

#28 booleanbalaji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 28-September 12

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.
Was This Post Helpful? 0
  • +
  • -

#29 jimblumberg  Icon User is online

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,681
  • Joined: 25-December 09

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
Was This Post Helpful? 0
  • +
  • -

#30 booleanbalaji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 28-September 12

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.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3