summaryrefslogtreecommitdiff
path: root/9p44.cpp
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-11-03 13:37:12 +0100
committerOskar <[email protected]>2024-11-03 13:37:12 +0100
commite485cf3dd08e024b24a6d01b495ff0de6835df6c (patch)
treef31ece63ea444c191be77bc945a9ab35514e5e7d /9p44.cpp
parent77b344e13eae4b4439f96a8d062151da03bf8263 (diff)
more, some unfinished stuff
Diffstat (limited to '9p44.cpp')
-rw-r--r--9p44.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/9p44.cpp b/9p44.cpp
new file mode 100644
index 0000000..263d122
--- /dev/null
+++ b/9p44.cpp
@@ -0,0 +1,34 @@
+#include <iostream>
+#include <string>
+
+/*
+ *
+ * 9.44
+ *
+ *
+ */
+
+std::string &replace_substr(std::string &s,
+ const std::string oldval,
+ const std::string newval) {
+
+ for(decltype(s.size()) i = 0 ; i < s.size() ; ) {
+ if(s.substr(i, oldval.size()) == oldval) {
+ s.replace(i, oldval.size(), newval);
+ i += newval.size();
+ } else {
+ ++i;
+ }
+ }
+
+ return s;
+}
+
+int main () {
+
+ std::string a = "hahahaha WOW a WO hah WOW WOW WOW";
+ std::string b = "tho though to tho yo tho bro tho";
+ std::cout << replace_substr(a, "WOW", "wow!") << std::endl;
+ std::cout << replace_substr(b, "tho", "though") << std::endl;
+ return 0;
+}