diff options
| author | Birducken <[email protected]> | 2022-11-07 22:34:51 -0800 |
|---|---|---|
| committer | Birducken <[email protected]> | 2022-11-07 22:34:51 -0800 |
| commit | 8b9c7c7d6275cc4cc963cab13b163b88a5476c86 (patch) | |
| tree | cc39e5b57351998e228b272bef91af0fe6668375 /CST116-Ch11-Debugging | |
| parent | Initial commit (diff) | |
| download | cst116-ch11-debugging-stark-8b9c7c7d6275cc4cc963cab13b163b88a5476c86.tar.xz cst116-ch11-debugging-stark-8b9c7c7d6275cc4cc963cab13b163b88a5476c86.zip | |
Finished exercise 1.
Diffstat (limited to 'CST116-Ch11-Debugging')
| -rw-r--r-- | CST116-Ch11-Debugging/CST116-Ch11-Debugging.cpp | 13 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj | 4 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters | 4 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/data.txt | 4 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/report.txt | 9 |
5 files changed, 26 insertions, 8 deletions
diff --git a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.cpp b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.cpp index 53830da..e2e41ae 100644 --- a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.cpp +++ b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.cpp @@ -81,9 +81,9 @@ int main() ifstream inFile; // Notice how this automatically opens the file - ofstream outFile("C:\\TEMP\\Chap_11_Report.txt"); + ofstream outFile("report.txt"); - inFile.open("C:\\TEMP\\Chap_11_data.txt"); + inFile.open("data.txt"); if (inFile.is_open()) { @@ -112,15 +112,12 @@ int main() int ReadData(ifstream& inFile, ofstream& outFile, char name[][MAX], int age[]) { int counter = 0; - inFile >> name[counter] >> age[counter]; // Priming Read while (!inFile.eof()) { - cout << setiosflags(ios::left) << setw(25) - << name[counter] << resetiosflags(ios::left) - << setw(4) << age[counter] << endl; - counter++; inFile >> name[counter] >> age[counter]; + cout << setiosflags(ios::left) << setw(25) << name[counter] << resetiosflags(ios::left) << setw(4) << age[counter] << endl; + counter++; } return counter; @@ -128,7 +125,7 @@ int ReadData(ifstream& inFile, ofstream& outFile, char name[][MAX], int age[]) void WriteOutputFile(ofstream& outFile, char name[][MAX], int age[], int counter) { outFile << " Here is the Output File" << endl; - for (int r = 0; r <= counter; r++) + for (int r = 0; r < counter; r++) { outFile << setiosflags(ios::left) << setw(25) << name[r] << setw(4) diff --git a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj index 2073e5b..6ad157a 100644 --- a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj +++ b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj @@ -129,6 +129,10 @@ <ItemGroup> <ClCompile Include="CST116-Ch11-Debugging.cpp" /> </ItemGroup> + <ItemGroup> + <Text Include="data.txt" /> + <Text Include="report.txt" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters index 2029dc7..faf4759 100644 --- a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters +++ b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters @@ -19,4 +19,8 @@ <Filter>Source Files</Filter> </ClCompile> </ItemGroup> + <ItemGroup> + <Text Include="data.txt" /> + <Text Include="report.txt" /> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/CST116-Ch11-Debugging/data.txt b/CST116-Ch11-Debugging/data.txt new file mode 100644 index 0000000..ac11bda --- /dev/null +++ b/CST116-Ch11-Debugging/data.txt @@ -0,0 +1,4 @@ +Gabe 6 +Myles 102 +Eden 32 +Barry 63
\ No newline at end of file diff --git a/CST116-Ch11-Debugging/report.txt b/CST116-Ch11-Debugging/report.txt new file mode 100644 index 0000000..f0ebfd7 --- /dev/null +++ b/CST116-Ch11-Debugging/report.txt @@ -0,0 +1,9 @@ + Here is the Output File +Gabe 6 +Myles 102 +Eden 32 +Barry 63 + + + ** Total Records: 4 ** + The End |