Nils
Lol you have undefined behavior
Something I plan caring about later.
Nils
First I want to care about performance
Anonymous
Your hands problem
You wrote code that doesn't work
Nils
Why? For me it works fine
Anonymous
First I want to care about performance
Are you stupid? Your wrote code that is shit
Nils
Are you stupid? Your wrote code that is shit
You are a veeeery good help -.-
Nils
Just tell me what is shit about it
Nils
Instead of just saying: "It's shit"
Anonymous
Just tell me what is shit about it
Line 22 You are passing pointers to different strings
Anonymous
Store the string first to a separate variable, then manipulate with c_str
Nils
Ah, okay. I'll try that
Anonymous
First I want to care about performance
You should not care about performance when your code is ill-formed
Nils
Ah, okay.
Nils
Nils
Ah, so jsoncpp is slow? Alright, thx for the suggestion
Anonymous
Till
@h4cktill, what's the fastest json library?
Rapidjson or boost (use rapidjson)
Nils
https://hastebin.com/pinelozaji.cpp Better?
Wow after that change the execution time skyrocketed! More than 1 second!
Nils
Rapidjson or boost (use rapidjson)
Okay, I'll rewrite using rapidjson
Till
@h4cktill, what's the fastest json library?
if you need only parse, simdjson your friend
Till
is it fast?
very very fast
Anonymous
no, just default stuff
Well, you should use at least -O2 flag
Nils
very very fast
Hmm but I need to dump it back to stdout
Nils
in jsoncpp I can simply do cout << root
Nils
does that work there too?
Till
does that work there too?
rapidjson, yes, but need more code simdjson - don't know
Nils
Rapidjson or boost (use rapidjson)
about rapijson: are the examples given in the docs good?
Anonymous
Nils
You can Google instead of asking
Googling such is critical
Nils
jsonarray[iternum].FindMember(sby)->value.GetString() is that correct?
Nils
it looks too odd to be correct lol
Iakovos
Guys need help in developing a windows shell in c language
Iakovos
Any help?
Anonymous
I_Interface
Iakovos
I mean what is F?
Anonymous
what's poppin
Nils
I am trying with rapidjson now, but… auto node = json_array_find_str_by_str(mesh["nodes"], "hostname", argv[1]) There must be some fundamental error here that I can't figure out.
Nils
error: ‘rapidjson::GenericValue<Encoding, Allocator>::GenericValue(const rapidjson::GenericValue<Encoding, Allocator>&) [with Encoding = rapidjson::UTF8<>; Allocator = rapidjson::MemoryPoolAllocator<>]’ is private within this context
Nils
What is wrong with it? auto node = json_array_find_obj_by_str(mesh["nodes"].GetArray(), "hostname", argv[1]); It causes a warning: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] json_array_find_obj_by_str is defined via: auto json_array_find_obj_by_str(auto jsonarray, char *sby, char *sfor)
Nils
Soved by excepting a const char*
Dima
that’s right, move from python to c++
Dima
:)
Nils
Also, I am trying to write a function that searches for a object in a list (rapidjson). However, the entry simply won't ever get found! auto json_array_find_obj_by_str(auto jsonarray, const char *sby, const char *sfor) { for (rapidjson::Value::ConstValueIterator itr = jsonarray.Begin(); itr != jsonarray.End(); ++itr) { std::cout << (*itr)[sby].GetString() << " : " << sfor << std::endl; if ((*itr)[sby].GetString() == sfor) { return (*itr).GetObject(); } } throw std::invalid_argument("No such node"); } (The assertion in line 4 does not work for some reason)
Anonymous
Hello, I am currently studying C, already know java and python, so i thought why not? lol
Anonymous
I am currently jotting my notes on wps office. heh.
MᏫᎻᎯᎷᎷᎬᎠ
.
Anonymous
char * or std::string?
Nils
The library is C not C++...
Anonymous
Char *
use std::strcmp() from <cstring> to compare C-style strings
Nils
use std::strcmp() from <cstring> to compare C-style strings
Ah, alright, thank you. Saved it. Do I need to import any other library?
Anonymous
Ah, alright, thank you. Saved it. Do I need to import any other library?
no, <cstring> is part of the standard library
Nils
Btw can you write a program without syscalls? Just out of interest as even if it is just int main() {} there are 20+ syscalls already.
Nils
Even though exactly the same in assembly has just one: exit()
Anonymous
Thx
btw if your project is C++17 or above, you can also use std::string_view to create a view into the string. operator== works on string_views
Anonymous
Help me please. I am just learn pointer . I have a basic example Split array into positive and nagative. But it’s not right
Anonymous
Anonymous
Artöm
You dont free allocated memory
Anonymous
No. I used free function. Second picture.
MᏫᎻᎯᎷᎷᎬᎠ
1-Make two arrays(neg, pos) with both having the half size of the primary array 1.1 make two index variable for both neg and pos 2-go to a loop through the elements of the primary array 3-inside the loop there are two conditions 3.1 if the current element is positive add it to the pos 3.2 else? Add it to neg Remember to increase the variables index of both pos and neg
MᏫᎻᎯᎷᎷᎬᎠ
Good luck
Artöm
No. I used free function. Second picture.
You allocate in cycle, free outside. Obviously yoy have a leak