summaryrefslogtreecommitdiff
path: root/BlankConsoleLab
diff options
context:
space:
mode:
authorBirducken <[email protected]>2022-11-29 12:59:05 -0800
committerBirducken <[email protected]>2022-11-29 12:59:05 -0800
commitbfc7eb5b135aba3520e6a0b9f5b8939b2208de44 (patch)
treeeda9c42bcebc0812d1f8fe8151d1308574f1d1b3 /BlankConsoleLab
parentRenamed files. (diff)
downloadarchived-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.vcxproj3
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj.filters5
-rw-r--r--BlankConsoleLab/cst116-lab3-stark.cpp31
-rw-r--r--BlankConsoleLab/small.txt6
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