Using scrnio.c and myio.h
After complaints from several students who were having difficulties using my posted scrnio.c and it's functions, I re-tested the source code. The test went fine, with no compile errors or warnings, and the resulting programs worked fine. What follows are the exact steps I did.
Instructions for using scrnio.c and myio.h with Borland C++ 5.02
1. From the New menu, select Project.
2. Set the Project Path and Name to C:\Work\School\C2\bTest (this
is OK for my machine)
3. Set Target model Console
4. Make sure the Class Library item is unchecked
5. Make sure that Static checked is selected
This made the empty project, though it had 3 windows-style files. I'm not sure why, but they are removed later (documented here).
6. From the File, then New menu, selected Text File.
7. Went to browser, selected and copied scrnio.c contents
8. Pasted into new text file
9. Saved as scrnio.c
10. Performed same steps as above, for myio.h
11. Deleted the 3 files that were created by Borland for my empty project:
12. In the Project window, I highlighted all 3 (a .cpp, .def, and
.rc file).
13. Hit the Del key.
Adding scrnio.c to your project:
14. Right-clicked in the Project window, and selected Add Node.
15. Selected the newly-created scrnio.c file.
16. Click OK
17. Went to File and New menu, and selected Text File
again.
18. Typed the following into the file:
#include "myio.h" void main() { int i; Cls(7); for( i=0; i < 16; i++ ) { Locate(i,i); CPrintStr("Test", i ); } GetKey(); Cls(7); }
19. Did a File / SaveAs from the menu, and saved it as
btest.c
20. Again, right-clicked in Project window, and selected Add Node.
21. Selected the new file created (btest.c), and clicked OK.
22. From the Project menu, I selected Build All.
The project built the .EXE, without any warnings or errors.
23. I then hit the lightning bolt to run the EXE file. It ran fine.
Instructions for using scrnio.c and myio.h with Visual C++ 5
1. Selected File, then New from the menu
2. In the New dialog, I selected Win32 Console Application.
3. Set Project Name to MTest.
4. Set Location to C:\Work\School\C2\ (this is OK for my machine)
5. Clicked OK
This made my empty console project.
6. Selected File then New from the menu. In the New
dialog:
7. Selected C++ Source File from the File tab.
8. Set File Name to scrnio.c
9. Clicked OK
10. Copied and pasted the scrnio.c from my browser into the scrnio.c file
11. Added a few blank lines at end of file
12. Saved file.
13. Selected File then New from the menu. In the New dialog:
14. Selected C/C++ Header file from the File tab
15. Set Filename to myio.h
16. Clicked OK
17. Copied and pasted the myio.c from my browser into the myio.h file
18. Added a few blank lines at end of file
19. Saved file.
20. Selected File then New from the menu. In the New dialog:
21. Selected C/C++ Header file from the File tab
22. Set Filename to MTest.c
23. Clicked OK
24. Typed the following into the file:
#include "myio.h" void main() { int i; Cls(7); for( i=0; i < 16; i++ ) { Locate(i,i); CPrintStr("Test", i ); } GetKey(); Cls(7); }
25. Saved file.
26. Pressed F7 to compile the program. Copiled without errors.
27. Pressed Ctrl-F5 to run the program. Ran without errors.