aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.cpp31
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.vcxproj1
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters3
-rw-r--r--CST116F2021-Lab5/Header1.h20
-rw-r--r--CST116F2021-Lab5/p.273.cpp39
-rw-r--r--CST116F2021-Lab5/p260.cpp53
6 files changed, 117 insertions, 30 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
index 7446117..380b00f 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
@@ -6,13 +6,14 @@
int main()
{
- char firstName[FIRST_NAME]{};
- char lastName[LAST_NAME]{};
- char fullName[FULL_NAME]{};
+ char string_1[INPUT_LIMIT]{};
+ char string_2[INPUT_LIMIT]{};
- GetFirst(firstName);
- GetLast(lastName);
- DispName(firstName, lastName, fullName)
+ GetInput(string_1, string_2);
+ CompareInput(string_1, string_2);
+ /*DispResult();*/
+
+ return 0;
}
@@ -20,6 +21,24 @@ int main()
+//int main()
+//{
+// char firstName[FIRST_NAME]{};
+// char lastName[LAST_NAME]{};
+// char fullName[FULL_NAME]{};
+//
+// GetFirst(firstName);
+// GetLast(lastName);
+// DispName(firstName, lastName, fullName);
+//
+// return 0;
+//}
+
+
+
+
+
+
//#include <iostream>
//
//using namespace std;
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
index 072f09b..78176c9 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
@@ -141,6 +141,7 @@
<ItemGroup>
<ClCompile Include="CST116F2021-Lab5.cpp" />
<ClCompile Include="p260.cpp" />
+ <ClCompile Include="p.273.cpp" />
<ClCompile Include="Source1.cpp" />
</ItemGroup>
<ItemGroup>
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters
index a3a1128..e06ec31 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters
@@ -24,6 +24,9 @@
<ClCompile Include="p260.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="p.273.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Header1.h">
diff --git a/CST116F2021-Lab5/Header1.h b/CST116F2021-Lab5/Header1.h
index 403d914..dd5bec7 100644
--- a/CST116F2021-Lab5/Header1.h
+++ b/CST116F2021-Lab5/Header1.h
@@ -2,13 +2,21 @@
using namespace std;
-void GetFirst(char[]);
-void GetLast(char[]);
-void DispName(char[], char[], char[]);
+void GetInput(char[], char[]);
+void CompareInput(char[], char[]);
+//void DispResult();
-const int FIRST_NAME = 15;
-const int LAST_NAME = 15;
-const int FULL_NAME = 2+FIRST_NAME + LAST_NAME;
+const int CHAR_LIMIT = 6;
+const int INPUT_LIMIT = 15;
+
+
+//void GetFirst(char[]);
+//void GetLast(char[]);
+//void DispName(char[], char[], char[]);
+//
+//const int FIRST_NAME = 15;
+//const int LAST_NAME = 15;
+//const int FULL_NAME = 2+FIRST_NAME + LAST_NAME;
//p.253
diff --git a/CST116F2021-Lab5/p.273.cpp b/CST116F2021-Lab5/p.273.cpp
new file mode 100644
index 0000000..fd493cd
--- /dev/null
+++ b/CST116F2021-Lab5/p.273.cpp
@@ -0,0 +1,39 @@
+#include "Header1.h"
+
+void GetInput(char input_1[], char input_2[])
+{
+ cout << "This program checks if the first six characters in a string are the same.\n";
+
+ cout << "Please enter your first string: ";
+ cin >> input_1;
+
+ cout << "Please enter your second string: ";
+ cin >> input_2;
+}
+
+void CompareInput(char comp_1[], char comp_2[])
+{
+ int i = 0;
+ do
+ {
+ if (comp_1[i] == comp_2[i])
+ {
+ if (i < CHAR_LIMIT-1)
+ {
+ i++;
+ }
+ else if (i == CHAR_LIMIT-1)
+ {
+ cout << "Same.";
+ i++;
+ }
+ }
+ else
+ cout << "Different.";
+ } while (i < CHAR_LIMIT);
+}
+
+//void DispResult()
+//{
+//
+//} \ No newline at end of file
diff --git a/CST116F2021-Lab5/p260.cpp b/CST116F2021-Lab5/p260.cpp
index d36cb5d..bef5a3c 100644
--- a/CST116F2021-Lab5/p260.cpp
+++ b/CST116F2021-Lab5/p260.cpp
@@ -1,18 +1,35 @@
-#include "Header1.h"
-
-void GetFirst(char inputFirst[])
-{
- cout << "Please enter your first name: ";
- cin >> inputFirst;
-}
-
-void GetLast(char inputLast[])
-{
- cout << "Please enter your last name: ";
- cin >> inputLast;
-}
-
-void DispName(char outputFirst[], char outputLast[], char outputFull[])
-{
-
-} \ No newline at end of file
+//#include "Header1.h"
+//
+//void GetFirst(char inputFirst[])
+//{
+// cout << "Please enter your first name: ";
+// cin >> inputFirst;
+//}
+//
+//void GetLast(char inputLast[])
+//{
+// cout << "Please enter your last name: ";
+// cin >> inputLast;
+//}
+//
+//void DispName(char outputFirst[], char outputLast[], char outputFull[])
+//{
+// int f = 0, l = 0;
+//
+// while (outputLast[l] != '\0')
+// {
+// outputFull[l] = outputLast[l];
+// l++;
+// }
+//
+// outputFull[l] = ',';
+// outputFull[l + 1] = ' ';
+//
+// while (outputFirst[f] != '\0')
+// {
+// outputFull[f+l+2] = outputFirst[f];
+// f++;
+// }
+//
+// cout << "Your full name is " << &outputFull[0] << '.';
+//} \ No newline at end of file