After a brief and rocky relation, I have had jilted Borland 5.02 and found new love for CODE::BLOCK only to discover a while ago that Borland could compile a code snippet which CODE::BLOCK couldn't.
In the working program produced below, CODE::BLOCK gave out an error message and failed to compile the original codes, where I used Void main(void) in the main function; it was adamant that it would only accept int main(void).
Then I realized that I should not have abandoned Borland, recalling fond memories that when you highlighted a C++ keyword, and pressed F1, you could get help readily, c/w explanations and examples of usage. CODE::BLOCK8.02 could not do this. In this respect, it is less user-friendly than Borland.
So, Borland need not be discarded, since its help is handily available. Perhaps, it can coexist with CODE::BLOCK, playing a different role, perhaps for lookup on explanation and usage of keywords, etc.
However, I have also discovered out that Borland has bad habits, being sometimes unpredictable and infested with bugs, and failing to compile on bug-free codes with the message "External errors" and could even tolerate the "Wrong thing" in compiling C++ codes with Void main(void), without any complaint, which I found to be like mixing with the wrong company.
Now, coming back to the main purpose of this thread, as shown in the title.. In the C++ codes below, I have remarked out // inp="", otherwise it would cause compiling to fail. So, I have used inp=NULL, and was let off with a warning, and compiling could be completed, and the program could run.
But, that line inp=NULL had been ignored on execution of the program. :(
It looks like a simple assignment of a character variable to NULL, for those familiar with other high level computer languages but i have not figured out how to do it in C++ yet.
I believe that the time a self-taught person take to learn C++ programming or any other skills in isolation would range from 3 X more to infinity -- which means not in a lifetime -- more compared with a person lucky to be pointed the right direction by a good and knowledgeable mentor, ceteris paribus. I also believe in Karma and that what goes around, comes around.
There is an intention to develop functions to make C++ programs more user-friendly. Ultimately, it is hoped that extended ASCII codes produced by pressing those Up, Dn, Left, Right, PgUp and PgDn keys could be used for data entry where Input type could be predetermined, and user is pre-empted from making errors before confirming with the Enter key. And the cursor can move from field to field, and page to page using extended keys mentioned above.
So, please help.
// ASCII-getche ASCII from keypress
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(void) {
system ("color 0a");
int c=0;
char inp;
//inp="":
do {
system("CLS");
cout << "\n\n\n\n\n\tThis program produces ASCII code for any key pressed.";
cout << "\n\n\n\n\n\tChar : " << inp << " ASCII: " << c <<"\n\n\n\tEsc to Exit,\tPresskey a key: ";
c = getche(); //* assign ASCII code to c
inp=c; // CHR$ from ASCII if extended, c=0
if (c==0) {
c=getche();
inp=NULL;
}
} while (c != 27); /* ESC to escape*/
cout << "\n\n\n\tBye\n\n\n";
getch();
}