diff options
| author | Lloyd Crawford <Lloyd Crawford@LAPTOP-7HJCDLE5> | 2022-11-09 16:38:01 -0800 |
|---|---|---|
| committer | Lloyd Crawford <Lloyd Crawford@LAPTOP-7HJCDLE5> | 2022-11-09 16:38:01 -0800 |
| commit | 97f55faef5d4e7a6844de89216077dce8c12ca3c (patch) | |
| tree | f8d7dd3dc7bea8faff9fb41c1483533c9d614bef | |
| parent | Initial commit (diff) | |
| download | cst116-ch11-debugging-19-ruin-97f55faef5d4e7a6844de89216077dce8c12ca3c.tar.xz cst116-ch11-debugging-19-ruin-97f55faef5d4e7a6844de89216077dce8c12ca3c.zip | |
| -rw-r--r-- | CH_11_Data_LC.txt | 10 | ||||
| -rw-r--r-- | CH_11_Report.txt | 15 | ||||
| -rw-r--r-- | CST116-CH11Debugging-Output-Crawford.txt | 20 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging.sln | 2 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/CST116-Ch11-Debugging-Crawford.cpp (renamed from CST116-Ch11-Debugging/CST116-Ch11-Debugging.cpp) | 23 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj | 6 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters | 5 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/~AutoRecover.CST116-Ch11-Debugging.vcxproj | 136 | ||||
| -rw-r--r-- | CST116-Ch11-Debugging/~AutoRecover.CST116-Ch11-Debugging.vcxproj2 | 139 | ||||
| -rw-r--r-- | CST116-Ch11-debugging-Pseudocode-Crawford.txt | 134 |
10 files changed, 479 insertions, 11 deletions
diff --git a/CH_11_Data_LC.txt b/CH_11_Data_LC.txt new file mode 100644 index 0000000..5595a0d --- /dev/null +++ b/CH_11_Data_LC.txt @@ -0,0 +1,10 @@ +Vincent 24 +Johnny 81 +Hector 45 +Ranni 89 +Radahn 90 +DrLivesly 45 +Powerwolf 10 +Iggy 23 +Bertrum 15 +Goofy 99
\ No newline at end of file diff --git a/CH_11_Report.txt b/CH_11_Report.txt new file mode 100644 index 0000000..6438727 --- /dev/null +++ b/CH_11_Report.txt @@ -0,0 +1,15 @@ + Here is the Output File +Vincent 24 +Johnny 81 +Hector 45 +Ranni 89 +Radahn 90 +DrLivesly 45 +Powerwolf 10 +Iggy 23 +Bertrum 15 +Goofy 99 + + + ** Total Records: 10 ** + The End diff --git a/CST116-CH11Debugging-Output-Crawford.txt b/CST116-CH11Debugging-Output-Crawford.txt new file mode 100644 index 0000000..f453fb9 --- /dev/null +++ b/CST116-CH11Debugging-Output-Crawford.txt @@ -0,0 +1,20 @@ +Output + +Vincent 24 +Johnny 81 +Hector 45 +Ranni 89 +Radahn 90 +DrLivesly 45 +Powerwolf 10 +Iggy 23 +Bertrum 15 +Goofy 99 + + + ** Total Records: 10 ** + The End + +C:\Users\Lloyd Crawford\source\repos\cst116-ch11-debugging-19-Ruin\x64\Debug\CST116-Ch11-Debugging-Crawford.exe (process 22772) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . diff --git a/CST116-Ch11-Debugging.sln b/CST116-Ch11-Debugging.sln index f71ac42..57d8906 100644 --- a/CST116-Ch11-Debugging.sln +++ b/CST116-Ch11-Debugging.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32929.385 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CST116-Ch11-Debugging", "CST116-Ch11-Debugging\CST116-Ch11-Debugging.vcxproj", "{2F33289E-7D00-4EC4-9951-F3DB9CD7C178}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CST116-Ch11-Debugging-Crawford", "CST116-Ch11-Debugging\CST116-Ch11-Debugging.vcxproj", "{2F33289E-7D00-4EC4-9951-F3DB9CD7C178}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.cpp b/CST116-Ch11-Debugging/CST116-Ch11-Debugging-Crawford.cpp index 53830da..623683f 100644 --- a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.cpp +++ b/CST116-Ch11-Debugging/CST116-Ch11-Debugging-Crawford.cpp @@ -1,6 +1,7 @@ /******************************************************************** * File: Chapter 11 Debug.cpp -* +* Lloyd Crawford, CST 116 02, Chapter 11 Debug, Github + * General Instructions: Complete each step before proceeding to the * next. * @@ -18,13 +19,13 @@ * 4) Build and execute the program. * 5) Update the file paths below to correctly represent the path you * created. -* 6) Rebuild and execute the program. +* 6) Rebuild and execute the program. Wont run program as path is not established. * 7) Examine the code and the output and notice the use of * parallel arrays. * 8) Add the output file created via the execution of * your program to your Project. Execute your program again * and notice how Visual Studio has rewritten your output file -* and asks if you would like to reload the file (select Yes). +* and asks if you would like to reload the file (select Yes). * 9) Examine the contents of both the input and the output file. * 10) Fix all the problems in your code that exist in relation to * the output. Verify that your output is appropriate for your @@ -53,7 +54,7 @@ * ********************************************************************/ #include <iostream> -#include <fstream> // For the files!!!! +#include <fstream> // For the files!!!! // lol stream......good thing its not a pstream ^o^ . #include <iomanip> // For manipulators & formatting options using std::cin; using std::cout; @@ -81,10 +82,10 @@ int main() ifstream inFile; // Notice how this automatically opens the file - ofstream outFile("C:\\TEMP\\Chap_11_Report.txt"); - - inFile.open("C:\\TEMP\\Chap_11_data.txt"); + ofstream outFile("C:\\Users\\Lloyd Crawford\\source\\repos\\cst116-ch11-debugging-19-Ruin\\CH_11_Report.txt"); + inFile.open("C:\\Users\\Lloyd Crawford\\source\\repos\\cst116-ch11-debugging-19-Ruin\\CH_11_Data_LC.txt"); + // double slash has to be used in all file in or out. If you use a single slach bad things happen. if (inFile.is_open()) { record_counter = ReadData(inFile, outFile, name, age); @@ -122,13 +123,19 @@ int ReadData(ifstream& inFile, ofstream& outFile, char name[][MAX], int age[]) counter++; inFile >> name[counter] >> age[counter]; } + // next segment is for reading and priming the file. + cout << setiosflags(ios::left) << setw(25) + << name[counter] << resetiosflags(ios::left) + << setw(4) << age[counter] << endl; + counter++; + inFile >> name[counter] >> age[counter]; return counter; } 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++) // femove the = here to stop the report from adding wierd coding to your solution and your file. nasty bug. { 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..1c5380a 100644 --- a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj +++ b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj @@ -24,6 +24,7 @@ <ProjectGuid>{2f33289e-7d00-4ec4-9951-f3db9cd7c178}</ProjectGuid> <RootNamespace>CST116Ch11Debugging</RootNamespace> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + <ProjectName>CST116-Ch11-Debugging-Crawford</ProjectName> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> @@ -127,7 +128,10 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <ClCompile Include="CST116-Ch11-Debugging.cpp" /> + <ClCompile Include="CST116-Ch11-Debugging-Crawford.cpp" /> + </ItemGroup> + <ItemGroup> + <Text Include="..\CH_11_Data_LC.txt" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters index 2029dc7..42b6d8a 100644 --- a/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters +++ b/CST116-Ch11-Debugging/CST116-Ch11-Debugging.vcxproj.filters @@ -15,8 +15,11 @@ </Filter> </ItemGroup> <ItemGroup> - <ClCompile Include="CST116-Ch11-Debugging.cpp"> + <ClCompile Include="CST116-Ch11-Debugging-Crawford.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> + <ItemGroup> + <Text Include="..\CH_11_Data_LC.txt" /> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/CST116-Ch11-Debugging/~AutoRecover.CST116-Ch11-Debugging.vcxproj b/CST116-Ch11-Debugging/~AutoRecover.CST116-Ch11-Debugging.vcxproj new file mode 100644 index 0000000..b00994d --- /dev/null +++ b/CST116-Ch11-Debugging/~AutoRecover.CST116-Ch11-Debugging.vcxproj @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>16.0</VCProjectVersion> + <Keyword>Win32Proj</Keyword> + <ProjectGuid>{2f33289e-7d00-4ec4-9951-f3db9cd7c178}</ProjectGuid> + <RootNamespace>CST116Ch11Debugging</RootNamespace> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + <ProjectName>CST116-Ch11-Debugging-Crawford</ProjectName> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="CST116-Ch11-Debugging-Crawford.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/CST116-Ch11-Debugging/~AutoRecover.CST116-Ch11-Debugging.vcxproj2 b/CST116-Ch11-Debugging/~AutoRecover.CST116-Ch11-Debugging.vcxproj2 new file mode 100644 index 0000000..c502ba8 --- /dev/null +++ b/CST116-Ch11-Debugging/~AutoRecover.CST116-Ch11-Debugging.vcxproj2 @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>16.0</VCProjectVersion> + <Keyword>Win32Proj</Keyword> + <ProjectGuid>{2f33289e-7d00-4ec4-9951-f3db9cd7c178}</ProjectGuid> + <RootNamespace>CST116Ch11Debugging</RootNamespace> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + <ProjectName>CST116-Ch11-Debugging-Crawford</ProjectName> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="CST116-Ch11-Debugging-Crawford.cpp" /> + </ItemGroup> + <ItemGroup> + <Text Include="..\CH_11_Data_LC.txt" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/CST116-Ch11-debugging-Pseudocode-Crawford.txt b/CST116-Ch11-debugging-Pseudocode-Crawford.txt new file mode 100644 index 0000000..fec69e4 --- /dev/null +++ b/CST116-Ch11-debugging-Pseudocode-Crawford.txt @@ -0,0 +1,134 @@ +Ch 11 Debug Pseudocode + + +Wrote own file & named it CH_11_Data_LC.txt +Replaced location of older file with new file location and name of file. +Had to debug own coding for a new file location as I had made my input my output +causing it to write over my input. Found errors in the code and fixed them. +Duplicated the while loop to be outside of the while and inside. +Changed <= to < on line 137 + In part 2 if you change the input from double slash to single slash it will cause the program to fail. + double slash is always a requirement. + Changing and tampering with input and output placements causes error coding. Best way is to copy the address of the file you use by going + to the files properties and copying it's address. + + #include <iostream> +#include <fstream> // For the files!!!! // lol stream......good thing its not a pstream ^o^ . +#include <iomanip> // For manipulators & formatting options +using std::cin; +using std::cout; +using std::endl; +using std::setw; +using std::ios; + +using std::ifstream; +using std::ofstream; + +const int EMPLOYEES = 20; +const int MAX = 21; + +int ReadData(ifstream& inFile, ofstream& outFile, char name[][MAX], int age[]); +void WriteOutputFile(ofstream& outFile, char name[][MAX], int age[], + int counter); +void PrintTotalsAndSummary(ofstream& out, int totalRecords); + +int main() +{ + char name[EMPLOYEES][MAX]; + int age[EMPLOYEES]; + int record_counter(0); + + ifstream inFile; + + // Notice how this automatically opens the file + ofstream outFile("C:\\Users\\Lloyd Crawford\\source\\repos\\cst116-ch11-debugging-19-Ruin\\CH_11_Report.txt"); + + inFile.open("C:\\Users\\Lloyd Crawford\\source\\repos\\cst116-ch11-debugging-19-Ruin\\CH_11_Data_LC.txt"); + // double slash has to be used in all file in or out. If you use a single slach bad things happen. + if (inFile.is_open()) + { + record_counter = ReadData(inFile, outFile, name, age); + inFile.close(); + + if (outFile.is_open()) + { + WriteOutputFile(outFile, name, age, record_counter); + PrintTotalsAndSummary(outFile, record_counter); + outFile.close(); + } + else + { + cout << "Trouble Opening File"; + cout << "\n\n\t\t ** About to EXIT NOW! ** "; + } + } + else + { + cout << "Trouble Opening File"; + cout << "\n\n\t\t ** About to EXIT NOW! ** "; + } + return 0; +} +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]; + } + // next segment is for reading and priming the file. + cout << setiosflags(ios::left) << setw(25) + << name[counter] << resetiosflags(ios::left) + << setw(4) << age[counter] << endl; + counter++; + inFile >> name[counter] >> age[counter]; + + return counter; +} +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++) // femove the = here to stop the report from adding wierd coding to your solution and your file. nasty bug. + { + outFile << setiosflags(ios::left) << setw(25) + << name[r] << setw(4) + << resetiosflags(ios::left) << age[r] + << endl; + } +} +void PrintTotalsAndSummary(ofstream& outFile, int totalRecords) +{ + // To screen + cout << "\n\n\t** Total Records: " << totalRecords << " **\n" + << "\t\t The End \n"; + + // To file + outFile << "\n\n\t** Total Records: " << totalRecords << " **\n" + << "\t\t The End \n"; + + Felt like I learned in this lesson and once I found how to do it, it felt like it went quick. + output + Vincent 24 +Johnny 81 +Hector 45 +Ranni 89 +Radahn 90 +DrLivesly 45 +Powerwolf 10 +Iggy 23 +Bertrum 15 +Goofy 99 + + + ** Total Records: 10 ** + The End + +C:\Users\Lloyd Crawford\source\repos\cst116-ch11-debugging-19-Ruin\x64\Debug\CST116-Ch11-Debugging-Crawford.exe (process 18708) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . |