From 68df371139054bd50bf60f5c1b4b735a0aeedbf3 Mon Sep 17 00:00:00 2001 From: Fightingkeyboard Date: Thu, 29 Mar 2018 10:55:49 -0400 Subject: [PATCH 1/2] read over & commented --- README.md | 11 ++++++++++- lab_08/funcs.cpp | 15 +++++++++++++-- lab_08/text.txt | 8 ++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 lab_08/text.txt diff --git a/README.md b/README.md index ec9560d..d1fcc99 100644 --- a/README.md +++ b/README.md @@ -1 +1,10 @@ -# CSCI136part2 \ No newline at end of file +# CSCI136part2 +## Forked by Anthony +### Observations Here +### Commented in code + +1. Has uses namespace std, MZ disapproves. +2. File funcs.cpp consists of removeLeadingSpaces and countChar. +3. Tried to stream input from text file. Unsucessful in current iteration. +4. Does not contain unindent or indent functions. +5. Functions work. \ No newline at end of file diff --git a/lab_08/funcs.cpp b/lab_08/funcs.cpp index 186a7b8..2f6b025 100644 --- a/lab_08/funcs.cpp +++ b/lab_08/funcs.cpp @@ -1,19 +1,29 @@ #include #include +//using a namespace using namespace std; - string removeLeadingSpaces(string line){ + + //counter int i=0; + + //while loop to find first !space while(isspace(line[i])){ i++; } + + //returns line without leading spaces return line.substr(i,line.length()-i); } int countChar(string line, char c){ + + //counter int o = 0; + + //for loops to find matches to c, adding to o every time matched for(int i=0; i Date: Thu, 29 Mar 2018 11:02:50 -0400 Subject: [PATCH 2/2] added missing functions --- README.md | 3 ++- lab_08/funcs.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1fcc99..7f76a34 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,5 @@ 2. File funcs.cpp consists of removeLeadingSpaces and countChar. 3. Tried to stream input from text file. Unsucessful in current iteration. 4. Does not contain unindent or indent functions. -5. Functions work. \ No newline at end of file +5. Functions work. +6. Added unindent and indent functions. \ No newline at end of file diff --git a/lab_08/funcs.cpp b/lab_08/funcs.cpp index 2f6b025..da6bc68 100644 --- a/lab_08/funcs.cpp +++ b/lab_08/funcs.cpp @@ -32,6 +32,25 @@ int countChar(string line, char c){ return o; } +string unindent(std::string line){ + string result; + result += removeLeadingSpaces(line) + "\n"; + return result; + + string indent(){ + int tabs = 0; + string result; + string line; + while (getline(cin, line)){ + line = unindent(line); + tabs -= countChar(line, '}'); + for (int i = 0; i < tabs; i++){ + result += "\t"; + } + } + return result; + } + //Trying to read from a file to test? I only inputted from the terminal /* int main(){