Anonymous
store the vector itself instead of an iterator lol
Nils
Oh. 🙈
Anonymous
yes
Nils
aaah.
Nils
yes
std::vector<std::string>::iterator cmdsplit = strsplit(commandstr, ' ', 1); auto cmdsplit_it = cmdsplit.begin(); error: conversion from ‘std::vector<std::__cxx11::basic_string<char> >’ to non-scalar type ‘std::vector<std::__cxx11::basic_string<char> >::iterator’ {aka ‘__gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >’} requested
nav
Why is Linux kernel written in C and not in C++? wouldn't OO make things easier?
Anonymous
aaah.
btw if you pass 0 to times, the function splits the string_view unlimited times based on the delimiter and the size of the string_view. either mark it as a feature and document it using a default argument (i changed my code), or throw an exception when times is 0
Anonymous
Hi guys. I've encountered an issue while writing a simple IRC client/server in C. At some point in the code I've used wgetch to take input from the keyboard. here's the tricky part. Let's say I press the 'f' key. The value returned from wgetch is 'f'. After that I input the pointer to that value inside a method. While debugging, it looks like &value is 'ff' like I pressed the 'f' key twice.. How come? I can send the source code if needed
Nils
terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid Aborted (core dumped)
Nils
Oh wait
Nils
wow it works when entering a working command
Nils
wow it works when entering a working command
But as soon as I input an incorrect one… It fail. But ig I can solve that myself
Nils
use a better IDE or more static analysis
Can you recommend me one? A OSS one?
Anonymous
Uhm
Anonymous
Can you recommend me one? A OSS one?
clangd provides static analysis. vim should have a plugin.
Anonymous
Nils
O.o what error?
Well, if the searched for char is not inside the given string it crashes
Nils
But probably I can fix it myself!
Anonymous
Nils
it should return npos if find_first_of fails :/
Hmm it should just return a vector with just one element if it is not found
Anonymous
How? :)
https://stackoverflow.com/questions/313555/light-c-unicode-library
Nils
Hmm it should just return a vector with just one element if it is not found
So... split("hiho", 'ä', 1) Should return a vector with the only element: {"hiho"}
Anonymous
https://www.urionlinejudge.com.br/judge/en/tournaments/rank/3572 If anyone wants to join this competetive programming contest, starts at 9 o clock
Anonymous
So... split("hiho", 'ä', 1) Should return a vector with the only element: {"hiho"}
this might be a problem with how the comparison function works. try a normal character.
Nils
So... split("hiho", 'ä', 1) Should return a vector with the only element: {"hiho"}
if (to_return == std::string_view::npos) to_return.push_back(s); Seems to not work…
Anonymous
Anonymous
@leoleoecdsa_bot Do I need to buy a tutorial when learning the C language of mooc
Dima
lol
Anonymous
?
Dima
buying tutorials in 2020
Anonymous
Nils
oh. then lemme test
Also affected delemiters won't get removed…
Anonymous
I do n’t think it ’s necessary either, just check C Prime plus
Nils
Okay. thx
Anonymous
Nils
fixed
cool, thx
Anonymous
Nils
Thx
Nils
ye
Wait what does it return if the delimiter is not in the string?
Nils
terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid Aborted (core dumped) Seems like it still returns something invalid… But wait! I know why!
Nils
I do not check the size
Nils
std::vector<std::string> cmdsplit = strsplit(commandstr, ' ', 1); auto cmdsplit_it = cmdsplit.begin(); std::string command = *cmdsplit_it; std::string argsstr; try { cmdsplit_it++; argsstr = *cmdsplit_it; } catch (const std::logic_error& e) { argsstr = ""; } Segmentation fault 🤔
Nils
oh.
Anonymous
How dafuq is this possible? The pointer to 'd' apparently points to 'dd'
Anonymous
Something is not right
Anonymous
likely your IDE's fault. interpreting the char * as a C-style string
Anonymous
maybe the third memory location has a null character where it stops
Anonymous
How can I solve it? 😬
Anonymous
I do not check the size
that test was unnecessary. i corrected the code again.
Anonymous
How can I solve it? 😬
you don't need to. just ignore it.
Nils
that test was unnecessary. i corrected the code again.
What does it return now if the delimiter was not found?
Anonymous
you don't need to. just ignore it.
I can't ignore it. The value that gets passed inside the method is uncorrect. 'dd' gets passed instead of 'd'
Serenity
Can anyone help me with this recursive problem ?
Anonymous
Can anyone help me with this recursive problem ?
goo.gl/search?recursion+lecture+notes+pdf
Serenity
Thanks a lot for the helpful link
Anonymous
Thanks a lot for the helpful link
actually removing the discrete maths gives more pdfs, edited
sanyogeeta
Hii everyone