Lab 00 - Hello World
References
FAQ
Description
"Create a C++ program to verify the web submission process for your labs."
Learning Outcomes
By completing the Hello Lab, you will have:
- Used an IDE (Visual Studio preferred) to write and compile a C++ program.
- Verified your course submission folder has been created.
- Completed a course lab submission process.
- Tested passing command line arguments to a program.
- Note how the auto-grader reports results, including memory leaks.
- NOTE: THERE IS NO GRADING VALUE FOR THIS LAB!
Preparation
Install Visual Studio Community 20xx on your computer.
Documentation and installation steps for Windows Visual Studio 20xx can be found here.
The Lab
Use the following steps in creating your lab:
- Run Visual Studio Community and create an empty project.
- Add the following C++ .cpp file
(or write your own) to your project:
#include <iostream> #include <fstream> #include <string> using namespace std; #ifdef _MSC_VER #define _CRTDBG_MAP_ALLOC #include <crtdbg.h> #define VS_MEM_CHECK _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #else #define VS_MEM_CHECK #endif /** Write input file lines (as specified by argv[1]) to output file (as specified by argv[2]). */ int main(int argc, char* argv[]) { VS_MEM_CHECK // enable VS check for memory leaks if (argc < 3) return 3; ifstream in = ifstream(argv[1]); // open argv[1] for input if (!in) return 1; ofstream out = ofstream(argv[2]); // open argv[2] for output if (!out) return 2; // read input file lines and send to output file for (string line; getline(in, line);) { out << line << endl; } // **LEAK SOME MEMORY - REMOVE FOR FULL CREDIT** int* memory = new int(100); return 0; }
- Set breakpoint on return statement to verify message.
- Compile and execute.
- Zip your hello.cpp file.
- Submit the .zip folder and verify auto-grader results.
Hello World Grading Criteria
Instructions for submitting your lab:
- Zip all your lab source files (.cpp, .hpp, .h) into one folder. DO NOT INCLUDE YOUR WHOLE PROJECT!
- Submit your zipped lab source folder using the "Labs" tab on the class website.
- Your submitted lab source will be compiled and executed using a Linux g++ compiler.
- Both input and output files will be specified by command line arguments.
- An auto-grader will compare your output files with expected results and you will shortly receive a score.
- The auto-grade process may abort on the first error. If so, correct the error and try again.
- You may re-submit your zipped source as many times as you like.
- No score will be recorded for this lab nor is there a peer review!
Use the following test input and resulting output files in testing your Hello World lab.
Input File | Output File | |
Test #1 | lab00_in_01.txt | lab00_out_01.txt |
Test #2 | lab00_in_02.txt | lab00_out_02.txt |
The auto-grader will grade your lab as follows:
Fail |
Pass
|
||
---|---|---|---|
There is no peer review for this lab. However, if there were a peer review, the following rubric would be used:
No |
Partial |
Yes
|
||
---|---|---|---|---|
Overall Rating |
Easy to follow, readable, organized, and
well commented. |
|||
***NOTE: Any attempt to circumvent any lab requirement (ie, hard coding output, using loops instead of iterators where required, modifying a class interface, etc.) will be reported by peer reviewers and result in a zero score for the lab. |
Total Score = 0