| | |
txt program?!HELP ME
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2008
Posts: 10
Reputation:
Solved Threads: 0
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
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
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.
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.
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.
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.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <conio.h> using namespace std; #pragma warning(disable: 4996) int main() { int x = 0; x = getche(); if(x == 0) { // function and arrow keys here // They are made negative values here // so that they can be distinguished // from normal keys x = -getche(); } cout << x << "\n"; }
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.
![]() |
Similar Threads
- Simple login (read data through txt file) (Visual Basic 4 / 5 / 6)
- How do i make my program work for 5 times and then Expire (VB.NET)
- Please Help, have been working on this Program for awhile and dissapointed in Results (C++)
- C Program where gets(), getchar(), are not working. (C)
- C++ How can read from file.txt & where can save this file(file.txt) to start reading (C++)
- VBScript disk quota program - whats up? (Visual Basic 4 / 5 / 6)
- Another Program Launching mine (C++)
- File Saving / Reading - Non Constant Folder? Help needed (Visual Basic 4 / 5 / 6)
- help for program involving switch loops and file (C++)
- Help with compression program (C)
Other Threads in the C++ Forum
- Previous Thread: C++ Class Design Resources
- Next Thread: i dont understand how this code thing works to put up a program. what does it mean?
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






