𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Great, thanks, I'll look for ncurses then
hello
hi is it possible to use a file pointer name in a function in another c file where it is not declared?
Fl
Hello
klimi
There is, but this group is not for this :)
Ahmed
What??
Dima
banhammer incomin'
Fl
Easy*
ʙoᴍо͠ʏ
can anyone name an example of variable declaration
ʙoᴍо͠ʏ
ʙoᴍо͠ʏ
I need 5 example
Kirk
You do the other 4, it's not hard, use other types too
ʙoᴍо͠ʏ
You do the other 4, it's not hard, use other types too
is it like this for example int integer;
Kirk
Yes
ʙoᴍо͠ʏ
Or #include <iostream> using namespace std; int main() { int myNum = 15; cout << myNum; return 0; }
ʙoᴍо͠ʏ
what about variable initialization
Iwan
if you need to learn faster, then you need to practice....more and more...you do it every hours everyday
Iwan
Brother how to learn fast any programming concept
when i learn something new like malbolge programming that i've learn, i take all of my time to practice and practice. i never stop until i can do it by my self. Theory can not help you if you are not do it. Practice can help you to be faster when you learn something new. Theory then practice, theory and practice.
dej
Hello guys, I need some help with converting a private chat based on tcp to udp
dej
I have some problems with multithread
dej
I can manage one single client
dej
But I have some issues with managing multiple clients
dej
can I share my github so that someone could see the issue?
Marlo
Any programing platform which is easier than visual studio??
dej
I can’t share my GitHub link
klimi
can I share my github so that someone could see the issue?
@includej: https://github.com/includej/SoProject There are two folders. One for a private chat written in Tcp and another one for UDP. tcp private chat works perfectly Udp works just with one client.
Elil 50
Do I really need to initialize the array before the Macro? https://imgur.com/a/DhwmEGV
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi, is there a way to spawn a new terminal command line on Linux from C? I'm working on Ubuntu, but I would need this method to work for every linux distro. This new window should appear when a certain signal is handled, the user does stuff, then should disappear. Can you direct me to some documentation or maybe a video, or anything, to both create and close the terminal window? Thanks!
klimi
You can just execute new terminal that is not a problem... closing the new terminal window might be harder depending on how you want to do it... Probably you could remember the forked PID and then sigterm it
Pavel
How can I invoke destructors for an array that I constructed in-memory using placement new? void* data = allocateSomehow(); SomeType* myArr = new (data) SomeType[count]; ... myArr ->~ ??? // how can I destroy freeSomehow(data);
Pavel
For the record, what I want it for, I want to allocate memory for two arrays of different types in one allocation (sizes not known at compile time).
B S
Hey
B S
How can I take user input input in pair in 2d vector in c++
B S
Please help me
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
You can just execute new terminal that is not a problem... closing the new terminal window might be harder depending on how you want to do it... Probably you could remember the forked PID and then sigterm it
mmm the forked PID is a good idea actually, but I need the software to spawn it on its own. All in all, I set an alarm(240), which causes the software to be hit by the SIGALARM signal after 4 minutes. When this happens, the handler takes place. Since the former terminal window is already filled with some information that we can't delete, and the user needs to write stuff on the socket, I need the software to autospawn a window
klimi
and idk how it is on windows exactly with PIDs and stuff (I quite lack the knowledge of win interface)
klimi
How can I take user input input in pair in 2d vector in c++
ask for 2 inputs, std::Make_pair and push (or maybe emplace)
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
mmm then I could try a setsockopt to give control back to the process after 4 minutes
klimi
delete myArr
although this is not recommended afaik
klimi
delete myArr
(or maybe actually delete[] myArr... not sure)
klimi
mmm then I could try a setsockopt to give control back to the process after 4 minutes
or you could have the alarm and check how long the terminals were running
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
or you could have the alarm and check how long the terminals were running
I wouldn't know how to do it, but the PID thing you told me earlier will surely be useful
klimi
I wouldn't know how to do it, but the PID thing you told me earlier will surely be useful
well you could have in the main thread list of all spawned processes and you could remember like the timestamp when you have spawned them... or you could try some async lib (although that is probably overkill)
Pavel
delete myArr
delete also deallocates the memory (also by specific rules, it's not said how I get the memory)
Marlo
Any programing platform which is easier than visual studio??
Pavel
How can I invoke destructors for an array that I constructed in-memory using placement new? void* data = allocateSomehow(); SomeType* myArr = new (data) SomeType[count]; ... myArr ->~ ??? // how can I destroy freeSomehow(data);
OK, so in the end I do this: void* data = allocateSomehow(); SomeType* keysAlias = reinterpret_cast<SomeType*>(data); for (size_t i = 0; i < count; ++i) { new (keysAlias + i) SomeType(); } ... for (size_t i = 0; i < count; ++i) { (keysAlias + i)->~SomeType(); } freeSomehow(data); A lot of code, but at least generates no assembly for basic types
𐌂𐋅Ꝋ𐌍Ᏽ𐌄𐌍Ᏽ🫚
Fuk, sorry wrong typeing
𐌂𐋅Ꝋ𐌍Ᏽ𐌄𐌍Ᏽ🫚
Touch error
Dima
sure
klimi
Fuk, sorry wrong typeing
hehe, alright, i pardoned it
Dima
hehe, alright, i pardoned it
lol so you wanna say you believe this? so naive klimi, so naive
Anonymous
How can I invoke destructors for an array that I constructed in-memory using placement new? void* data = allocateSomehow(); SomeType* myArr = new (data) SomeType[count]; ... myArr ->~ ??? // how can I destroy freeSomehow(data);
You have to run the destructors for the individual elements of the array manually in the reverse order of construction. If your array is of type SomeType and the length of the array is len, thenyou have to do this: for(auto i = len - 1; i>= 0; i--){ data[i].~SomeType(); } freeSomeHow(data);
Anonymous
How can I invoke destructors for an array that I constructed in-memory using placement new? void* data = allocateSomehow(); SomeType* myArr = new (data) SomeType[count]; ... myArr ->~ ??? // how can I destroy freeSomehow(data);
No. Placement new constructs the elements in the memory you give to it. The default constructors would have run. Your job is to run the destructors. There is no equivalent to placement new for destruction of elements. You have to do it manually like I suggested above.
Pavel
No. Placement new constructs the elements in the memory you give to it. The default constructors would have run. Your job is to run the destructors. There is no equivalent to placement new for destruction of elements. You have to do it manually like I suggested above.
Yes, but won't it be more consistent if placement new will be also called per-object if we destroy them per object? Otherwise feels strange that we construct an array but destroy individual objects.
Anonymous
Why the order need to be reverse by the way, does it matter in which order they will be destroyed?
The usual standard way is for elements to be destructed in the reverse order of construction. It makes sense if you think that the element created last may depend on elements created before it. So destroying it first makes sense. All the STL containers follow that principle as well. It may not matter in your case but if you are designing a library, a user may use your library to create objects with dependencies. So destroying in the same order you created them may violate invariants of the User Defined Type and may lead to Undefined Behavior.
Anonymous
Yes, but won't it be more consistent if placement new will be also called per-object if we destroy them per object? Otherwise feels strange that we construct an array but destroy individual objects.
You shouldn't be using placement new then to construct the whole array. Create individual elements in the memory allocated as they would be laid out if in an array. Placement new just makes your job a lot easier.
Pavel
Another question, is this a right way of having two arrays of different types in the same piece of memory? https://wandbox.org/permlink/sUikkwSKXSmsEPYr
Pavel
I wonder if I introduced some UB or this looks fine UPD: nevermind, found that I'm doing something stupid with the alignment
Pavel
Your gapSize calculation is wrong.
Yes just saw it also, I don't know what I was thinking about 😓
Anonymous
how can i print the result of a^b in (c) with out using a loop?
emiteclap
how can i print the result of a^b in (c) with out using a loop?
cout<<a*b; printf("%d",a*b);
Elil 50
Do I really need to initialize the array before the Macro? https://imgur.com/a/DhwmEGV
H
Why private member functions are declared in c++?
mito
Why private member functions are declared in c++?
so that it is only used within the class itself and it's members.
Azat
Why private member functions are declared in c++?
I believe to be able to "hide" from user to avoid undesirable use of those functions. Like indexing which allows you both read and change the data but you want only user to be able to read it. In that case, you can make it private and implement read_by_index(int idx) {return a[idx]}
Azat
Probably bad example. Probably someone can give a better one
Anonymous
Why private member functions are declared in c++?
Because they are mostly implementation details and are not required to be part of the interface of the class. Because they can easily be changed without affecting the users of the class. Because they offer some common functionality that can be shared by other public member functions and hence not required to maintain invariants of the class. They hence can't be directly called by users.
mito
Maybe something like a Movie class where you can use a public method searchMovie(std::string) to search for a movie by sending request to a rest API hosted somewhere. First you will check what kind of response i.e status code you get for the request. You can create that method int returnStatusCode (); in private because it will be only used within the searchMovie() method and you don't want it to be accessible on the outside.
Anurag
How to convert a string input to raw string in cpp?