diff options
| author | Birducken <[email protected]> | 2022-11-29 12:59:05 -0800 |
|---|---|---|
| committer | Birducken <[email protected]> | 2022-11-29 12:59:05 -0800 |
| commit | bfc7eb5b135aba3520e6a0b9f5b8939b2208de44 (patch) | |
| tree | eda9c42bcebc0812d1f8fe8151d1308574f1d1b3 /BlankConsoleLab | |
| parent | Renamed files. (diff) | |
| download | archived-cst116-lab3-stark-bfc7eb5b135aba3520e6a0b9f5b8939b2208de44.tar.xz archived-cst116-lab3-stark-bfc7eb5b135aba3520e6a0b9f5b8939b2208de44.zip | |
Added file read opening system
Diffstat (limited to 'BlankConsoleLab')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.vcxproj | 3 | ||||
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.vcxproj.filters | 5 | ||||
| -rw-r--r-- | BlankConsoleLab/cst116-lab3-stark.cpp | 31 | ||||
| -rw-r--r-- | BlankConsoleLab/small.txt | 6 |
4 files changed, 35 insertions, 10 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj index efb619c..2ff956d 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj @@ -142,6 +142,9 @@ <ItemGroup> <ClCompile Include="cst116-lab3-stark.cpp" /> </ItemGroup> + <ItemGroup> + <Text Include="small.txt" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters index aca1dd9..970febb 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters @@ -15,8 +15,11 @@ </Filter> </ItemGroup> <ItemGroup> - <ClCompile Include="BlankConsoleLab.cpp"> + <ClCompile Include="cst116-lab3-stark.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> + <ItemGroup> + <Text Include="small.txt" /> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/BlankConsoleLab/cst116-lab3-stark.cpp b/BlankConsoleLab/cst116-lab3-stark.cpp index ed5f807..cd6405a 100644 --- a/BlankConsoleLab/cst116-lab3-stark.cpp +++ b/BlankConsoleLab/cst116-lab3-stark.cpp @@ -1,16 +1,29 @@ -// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - #include <iostream> - -using namespace std; +#include <fstream> +#include <string> +#include <iomanip> using std::cout; using std::cin; using std::endl; +using std::ifstream; +using std::string; +using std::setw; -int main() -{ - cout << "Hello World!\n"; -} +const int width = 10; + +int main() { + ifstream fin; + string fName; + + do { + cout << "Input file name: "; + cin >> fName; + fin.open(fName); + if (!(fin.is_open())) { + cout << "File couldn't be opened. Try again." << endl; + } + } while (!(fin.is_open())); + +} diff --git a/BlankConsoleLab/small.txt b/BlankConsoleLab/small.txt new file mode 100644 index 0000000..840aa56 --- /dev/null +++ b/BlankConsoleLab/small.txt @@ -0,0 +1,6 @@ +129 7 3 1.3 7.5 0 +36 69 1 11.41 32 5.76 +7 41 1 4.6 15 5.76 +150 61 2 6.75 23 0 +112 17 1 3.84 15 0 +80 112 6 1.64 9.5 0
\ No newline at end of file |