update: pushing the start ex04 of the module 01
This commit is contained in:
parent
2b197d8d05
commit
08a23cc42b
6 changed files with 291 additions and 0 deletions
45
cpp01/ex04/sed.cpp
Normal file
45
cpp01/ex04/sed.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* sed.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/11/05 15:58:02 by rparodi #+# #+# */
|
||||
/* Updated: 2024/11/05 21:58:30 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "sed.hpp"
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
|
||||
Sed::Sed(char **argv, std::ifstream *input)
|
||||
{
|
||||
_filename = argv[1];
|
||||
_filename += ".replace";
|
||||
_to_replace = argv[2];
|
||||
_by_word = argv[3];
|
||||
_input = input;
|
||||
}
|
||||
|
||||
Sed::~Sed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const char *Sed::getFilename()
|
||||
{
|
||||
return (_filename.c_str());
|
||||
}
|
||||
|
||||
bool Sed::line(std::ofstream output)
|
||||
{
|
||||
std::string to_ret;
|
||||
|
||||
if (!std::getline((*_input), to_ret))
|
||||
return (false);
|
||||
output << to_ret << std::endl;
|
||||
std::cout << to_ret << std::endl;
|
||||
return (true);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue