Indolent
Thanks for all of this help today. You're a pro!
Indolent
string s(1, 5);
Indolent
Does this means something?
Indolent
Or something like: string s(1, sample[5]) // here sample is a string eg: string sample = "abcd";
Cengizhan
Or something like: string s(1, sample[5]) // here sample is a string eg: string sample = "abcd";
No, actually this constructor fills string with the second parameter, times of second parameter.
Cengizhan
string s(2, 'n') -> "nn" for example.
Cengizhan
In your case, 5 is not ASCII character you cannot see what written in string probably. You should give valid character as a second parameter to string constructor if you want to use this one.
Anonymous
no, it's only a cookbook
There is actually a library with it
Anonymous
/get
Sasuke
I have a dynamic array of strings. Some elements contain tokens symbols like (|, &&, ||, ;) for example array ={"ls", "-la&&", "echo", "done"} So I want to proceess differently the elements before symbol and elments after symbol. How can I split the elements such that array look like this array ={"ls", "-la", "&&", "echo", "done"}
Martin
The simple but limited way is to hand write state machines to only split settings at the appropriate location.
Martin
The more complex also powerful approach is to use something like Flex/Bison to generate a full-blown parser. And use the parser to parse.
Martin
But location isn't fixed it's depended on input from user
So you need a state machine or something like it. You have to write a lot of code to determine when a spilt should happed within a loop that iterates over the entire string.
Martin
Plain 'split' won't do it.
Martin
What are these things
flex and bison are parser generators. Tell them what input is like. They generate a parser for the input
Martin
More or less, yes
Sasuke
More or less, yes
I also have single array of chars too if operation on that is easier
Martin
I also have single array of chars too if operation on that is easier
Do it on the array of chars. It will be a lot easier
Sasuke
Do it on the array of chars. It will be a lot easier
So I have to do something like this "ls -la&& echo done" convert it to "ls -la && echo done"
Sasuke
Space around symbol
Martin
Yes. You need to write a loop manually to do it. Create another array of chars thats long enough. Loop through the input array of characters. If you find a special symbol after a normal character. Add a space to the new array before copying the character
Sasuke
So I may end up adding extra space
Martin
Thing is again it's user depended it may or may not contain a leading or trailing space
Handle thats in your code. Just check if the character before the special one is a space or not
Martin
So I may end up adding extra space
This is where things get really tricky. The simple solution I described above have a lot of edge cases. It might insert extra spaces when it shouldn't (let's say, in a quoted string)
Martin
The only 100% correct way is to write a parser according to sh/bash/zsh 's grammar rules. It's gonna be very hard
Martin
But the simple way will get you 90% there.
Sasuke
Am already stressed
Dima
Okay
Aurora
who use cocos2d-x
I_Interface
lol
Taha
Hello guys what is the perfect library in c++ to work with encryption and thank u
Taha
Gmp
Thanks bro
数学の恋人
how does arbitrary precision in float work in C++? I have seen few libraries that provide arbitrary precision, like GMP, fprecision (Modified GMP), LEDA's bigfloat, etc. But I don't seem to find how they are actually doing it. I know I can just read the source code, but it's too long and I'm in kinda hurry and I want to implement it myself
Artöm
They store array of ints and use formulas to calculate stuff
数学の恋人
They store array of ints and use formulas to calculate stuff
ah wait I guess elementary maths will be useful if that's the case
Artöm
It definitely is
数学の恋人
it seems overwhelming once but isn't much of a deal
数学の恋人
thanks for reminding, very much appreciated.
Taha
Can i see the code source
Wisenky
https://github.com/tensorflow/tensorflow how do they compile this projects written in many languages
correctmaninwrongplace
Hello, i have a doubt, if i call std::vector<int> second (4); it will create a vector of 4 elements or just will create an empty vector with space for 4 elements?
Anonymous
But yeah it creates the vector of 4 elements
Anonymous
In Java or C# same data structures set the capacity
correctmaninwrongplace
cppreference.com :)
it says fill constructor Constructs a container with n elements. Each element is a copy of val (if provided). if provided, but if i dont provide it?
Anonymous
Look at the signature
val has default value
Anonymous
/get dsa
Anonymous
/get
ᡕᠵ᠊ᡃ࡚ࠢ࠘ ⸝່ࠡࠣ᠊߯᠆ࠣ࠘ᡁࠣ࠘᠊᠊ࠢ࠘𐡏⁻
I need the beat explain to know what is DLL
I_Interface
I need the beat explain to know what is DLL
lol banned from google ? https://support.microsoft.com/en-us/help/815065/what-is-a-dll
Wisenky
for me, the best are C++ and Python, the winners couple
how can I make a c++ project with using python files like that
Anonymous
how can I make a c++ project with using python files like that
i don't know. I'm making two different program
Patrick
Must I use unique_ptr or can I just delete the copy operator and constructor of my class?
Anonymous
There's no "copy operator"
Patrick
X& operator=(const X&)
Patrick
assignment
Anonymous
It's copy assignment operator
Anonymous
If you need to delete any function, you can add = delete; after its signature
Patrick
I'm thinking, instead of using this all the time: unique_ptr<X> in my class X I could just do: X& operator=(const X&) = delete; X(const X&) = delete;
Patrick
Is it functionally similar to unique_ptr in that it will prevent copies, and must be moved?
Anonymous
No one uses std::unique_ptr to prevent copies of objects
Patrick
No one uses std::unique_ptr to prevent copies of objects
A copy could free memory upon destruction, right? What is it used for if not managing lifetime to prevent an issue like that?