diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 11:26:50 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 11:26:50 +0100 |
| commit | b799c007a1b6911fcbe5141429ea541e1277ebdd (patch) | |
| tree | d70ad0826ad2fc2d635adf9afecf89af0838d20b /cpp01/ex07 | |
| parent | 1e9d90bdf9ef5fc05093d3449d883597c7f896de (diff) | |
| download | piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.gz piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.bz2 piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.zip | |
Fixing some edge cases in cpp00 and cpp01, Updated formatting
Diffstat (limited to 'cpp01/ex07')
| -rw-r--r-- | cpp01/ex07/Makefile | 4 | ||||
| -rw-r--r-- | cpp01/ex07/main.cpp | 13 |
2 files changed, 8 insertions, 9 deletions
diff --git a/cpp01/ex07/Makefile b/cpp01/ex07/Makefile index 1617d62..15c5518 100644 --- a/cpp01/ex07/Makefile +++ b/cpp01/ex07/Makefile @@ -6,12 +6,12 @@ # By: cacharle <marvin@42.fr> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/02/02 17:05:31 by cacharle #+# #+# # -# Updated: 2020/04/13 10:32:03 by charles ### ########.fr # +# Updated: 2020/11/09 11:15:17 by cacharle ### ########.fr # # # # **************************************************************************** # CXX = clang++ -CXXFLAGS= -Wall -Wextra -Werror +CXXFLAGS = -Wall -Wextra -Werror SRC = $(shell find . -type f -name "*.cpp") OBJ = $(SRC:.cpp=.o) diff --git a/cpp01/ex07/main.cpp b/cpp01/ex07/main.cpp index 64e5ce8..d98168a 100644 --- a/cpp01/ex07/main.cpp +++ b/cpp01/ex07/main.cpp @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/02 17:08:28 by cacharle #+# #+# */ -/* Updated: 2020/04/13 10:31:55 by charles ### ########.fr */ +/* Updated: 2020/11/09 11:22:46 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,27 +21,26 @@ int main(int argc, char **argv) std::cerr << "Usage: " << argv[0] << " filename s1 s2" << std::endl; return 1; } + std::string filename(argv[1]); std::string s1(argv[2]); std::string s2(argv[3]); - if (s1 == "" || s2 == "") + if (filename.empty() || s1.empty() || s2.empty()) { - std::cerr << "Error: s1 and s2 should not be empty" << std::endl; + std::cerr << "Error: filename, s1 and s2 should not be empty" << std::endl; return 1; } std::ifstream file(filename); std::ofstream outfile(filename + ".replace"); - if (!file) + if (!file.is_open()) { std::cerr << "Could not open " << filename; - outfile.close(); return 1; } - if (!outfile) + if (!outfile.is_open()) { std::cerr << "Could not create " << filename << ".replace"; - file.close(); return 1; } |
