txt program?!HELP ME

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 10
Reputation: xlx16 is an unknown quantity at this point 
Solved Threads: 0
xlx16 xlx16 is offline Offline
Newbie Poster

txt program?!HELP ME

 
0
  #1
May 10th, 2008
can u help me with this:
write a program that u can write in it and evrey time u press (F1) program will tell u number of capital letters in txt

if u press (F2) it tells u number of words(for exampel: 23 erf 3e has 3 words)

if u press any of the arrow keys cursor changes it`s position ,and when u
press back space it deletes the last character (just like the real back space)

thank u very much
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: txt program?!HELP ME

 
0
  #2
May 10th, 2008
First
http://www.catb.org/~esr/faqs/smart-...html#writewell

Then perhaps
http://www.catb.org/~esr/faqs/smart-...html#beprecise

Then restate your question in English (not kiddie script), and state the Operating system and compiler you want this to run on. And try to be more specific than say "windows" and "borland" for example.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,445
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1475
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: txt program?!HELP ME

 
0
  #3
May 10th, 2008
There is no standard way to do that in C or C++ because the languages don't know a thing about the function or arrow keys. But there are work-arounds and they all depend on your compiler and operating system.

One way is to use the curses library, or pdcurses on MS-Windows platforms. Its a little complicated and I'm not all that familiar with it.

Probably the easiest work-around is to use conio.h, if your compiler supports it. Below is a little program that illustrates one way to get function and arrow keys using getche(). When a special key is pressed you have to call getche() twice because the first time getche() returns 0 and the second time it returns the keycode for the key that was pressed. Special keys use the same key code as all other normal keys so you need to do something that will make them unique. I like to make them negative, but you could also just add 256 to them. Note this is the complexity of the MS-Windows operating system, not of the getche() function.

Run this program yourself and it will tell you the value of the key that was pressed, then you can use that value in your program for F1, F2, etc.
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4. #pragma warning(disable: 4996)
  5.  
  6. int main()
  7. {
  8. int x = 0;
  9. x = getche();
  10. if(x == 0)
  11. {
  12. // function and arrow keys here
  13. // They are made negative values here
  14. // so that they can be distinguished
  15. // from normal keys
  16. x = -getche();
  17. }
  18. cout << x << "\n";
  19. }
Last edited by Ancient Dragon; May 10th, 2008 at 10:06 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC