Hi com64,
It is good to hear from you again. I am sorry to hear that you are experiencing problems with your project. My best guess is that the other forums you have visited are not populated with software engineers and developers, and that is the reason that you are finding no problem resolution. I will address line numbers and your current example code in the later portion of this reply.
I believe that I may understand part of the hurdles in front of you. (The key word here is
may.) Bear with me because my explanation deals with the basics, not specifics. For the purpose of this explanation define
basics as "how Windows works" and
specifics as "what does the code look like". I really believe that this topic is graduate level programming --> far beyond what you and I are capable of right now in C++.
First and foremost Windows is written in a combination of C and C++; therefore, C++ is an appropriate language to use. Software and hardware drivers are written in either Assembly or C/C++. C++
does include the facility to embed Assembly code in a C++ program, but I am thinking that would make the code platform specific. My research of programming language history leads me to believe that both C and C++ were developed to facilitate cross-platform implementation of code. Editing or rewriting code from scratch to make it stable on different platforms is prohibitive.
The Windows operating systems do not directly execute code. Dynamic link libraries (dll) are used to automatically execute code. At my current level of understanding manually launching and executable file will not provide you with the results you desire because the various Windows processes (like svchost, for example) cannot provide dynamic, real time access to the code. I believe attempting to manually launch the code will result in either improper operation or crashes.
Because the specifics are beyond my knowledge base at present, the following is speculation based upon logical analysis of what I
do understand. I believe that you may find it necessary to use one of the following to implement your code:
.msi, .ini, or ,inf files.
You are modifying the Registry when using these files. Mistakes can result in a totally wrecked (bricked) operating system. Attempting to restore the computer using a System Restore point or a registry backup (like ERUNT) may not work for non-fatal errors. The safest method to attempt to install and debug programs like the one you wish to write is to mount a virtual machine (VM), and do your work within the VM until you are satisfied with the results. The VM protects the operating system from catastrophic failures. The VM can be restored from a snapshot much quicker and easier than reinstalling your operating system.
My complete ignorance of hardware interfaces leaves me with a big question. Do you need to know anything about compatible and incompatible ports? If so, you may need to research the ports available.
Let's move on to an answer you can take to the bank. Line numbers can be included in both the text editor and in printed code. I really like to have a hard copy to examine. The hard copy allows me to scribble, highlight, you name it during the debugging process before typing any corrections.
in the text editor:
Navigate
tools> options> text editor> all languages> general. In the right pane under
display, tick the line numbers box. Click OK.
for printed code:
Navigate
file> print. In the window that opens, find print what. Check the box for
include line numbers.
one more trick:
When you encounter a compiler error, you can double click the error in the output pane. Visual C++ will take you to the line of code with a cursor shown on the far left side of the test editor.
I have experienced no problems with the examples you asked about. Your problems with the console window are hard to address without seeing your code or know the method you use to open a new project. I can tell you what I do. That may make it unnecessary for your to post your code.
First I print the code and compare it to the book example, making corrections where I find errors. Some of the exercises have required modifications, but not the ones you listed.
My method for opening a new project is not exactly what the book recommends. I use methods I learned in my intro to programming class plus book instructions. Using the methods I list here resolved problems I encountered in some of the early book example code.
instructions not included in the book:
To begin with, navigate
tools> settings. Check
expert settings. You only have to do this once.
When opening a new Win32 project, do this every time.
- file> new> project
- After entering all info in the window and clicking OK, a new window opens.
- Click next, not finish.
- Choose console application and empty project.
- Click finish.
- Your work space opens.
continue with instructions form the book:- Right click source files.
- Choose add and new item.
- A window opens.
- Choose C++ File (.cpp) and name it.
- Click add.
Go back to the left pane.
- Right click the first bold entry, and choose properies.
- In the right pane under project defaults, find character set.
- Click the right column, and you will see a down arrow.
- Click the down arrow amd choose not set.
- Click OK.
Try the steps I use for new project t see if it resolves your window open problem. If it does not, post you code for my examination.
A quick heads-up for you --> In about a week and a half I will be starting classes in a new semester. I have loaded myself pretty heavy and may not be able to provide timely replies. Be patient. I will reply as time allows.
regards,
drpepper