Anonymous
And include for atomic
Atomic is there. The file is missing an include for array
Luka🇺🇦
I don't see a #include <array> in that file.
Thanks, helped. Now will try to fix next errors
Hussein
Hello programmer I am mr unknown. I'm thinking of learning c ++ right now. I'm new to programming. I don't know any of that. So I want the experts here to guide me. And let me explain where I should start. I am sure you will help me. ~Mr Unknown
start with a tutorial then start doing simple project by making mistakes you will learn new stuffs and get more experience search on the web for anything you don’t know and if you got stuck ask a question here this is how most of us started
Hussein
except for myself who didn’t know this group existed back then 😅
ÐΞΛÐ HΛϾКΞЯ
Gio
Hi guys
Noah
Hi
Hello, How can I detect whether a file stream/string stream is open with binary mode?
I have a class with text/bianry io implement, I wonder what is a good interface. I think I should use stream as interface, but I need to detect stream binary/text attribute to detect which method to call.
Prometheus
Can we use c++ for developing Web or apps better?
There's a good setup for it that one of our memeber's created. I can try to get in touch with him if you want.
Lyroy
Hello, is CMake considered off-topic?
klimi
Hello, is CMake considered off-topic?
You can ask to some extend here... it shouldn't be cmake only group tho, but i don't think you would get in trouble for asking since cmake is really related to C and C++.
klimi
alternatively you can just ofcourse ask in the offtopic group
Lyroy
Okay, thanks 👍 So, I'm making a small library with which (simplifying) I can call a function and execute a program/command. Example: auto r = Execute("echo hello"); r.stdOut will be hello. I have the basic setup with CMake. I managed to add a testing folder and make it work but I have a little problem. For testing I would like not to rely on the OS programs, but rely on some programs written by me. I want that every time I generate the testing executable other executables are generated, one from each .cpp file in a determined folder. I tried with a foreach but it kept giving me errors, how should I do this?
Anonymous
try to do some gdb, make a breakpoint and run it, checked up
Anonymous
or don't use the for_each, find a way to replace it
Hussein
Okay, thanks 👍 So, I'm making a small library with which (simplifying) I can call a function and execute a program/command. Example: auto r = Execute("echo hello"); r.stdOut will be hello. I have the basic setup with CMake. I managed to add a testing folder and make it work but I have a little problem. For testing I would like not to rely on the OS programs, but rely on some programs written by me. I want that every time I generate the testing executable other executables are generated, one from each .cpp file in a determined folder. I tried with a foreach but it kept giving me errors, how should I do this?
it depends on how complicated you want your design of the shell script you wanna make you have to start with lexical analysis which is how you will group letters together to create the first keyword then the next time you call it you for the next keyword like the folloing char * scan_script( char * script ) where it will return the first keyword each time you call it then you have to parse it which means to check whether the first keyword is a valid command then to go for the next keyword and you do the same until finally you execute the full command with all its parameters that’s in case you wanted to make a shell script to execute commands only not to do arithmatic or create functions like in a real programming language for that you will do the same but you have to create a syntax tree
● Igor
I replaced all my raw pointers with shared_ptr's and I'm using only make_shared, but something strange is happening... After all variables going out of scoped, I'm having 84 constructor calls (expected), but only 14 destructor calls https://pastebin.com/Zh7Yv9YL
tasya
//This is a program to identify the function calls using call by reference #include<iostream> using namespace std; void funct_ref(int &z1, int z2); //function prototype int main() { int x = 1; int y = 1; funct_ref(x, y); //call function cout<<"x is "<<x<<endl; cout<<"y is "<<y<<endl; } void funct_ref(int &z1, int z2) //function definition { z1++; z2++; }
tasya
can anyone explain to me why the x=2
\Device\NUL
z1 is referencing to x
tasya
i seee
tasya
#include <iostream> using namespace std; intmain() float Area_of_rectangle(float length,float width) { float area; area= length * width; return(area); }
Anonymous
#include<iostream> using namespace std; int main() { float salary,Incometax,pension,Netsalary; cout<<"Please enter the salary"; cin>>salary; if(salary>=3500) { Incometax=20%*(salary); pension=4%*salary; Netsalary=salary-pension-Incometax; } else if(salary>=2500) { Incometax=15%*salary; pension=4.0%*salary; Netsalary=salary-pension-Incometax; } else if(salary>=1000) { Incometax=10%*salary; pension=4%*salary; Netsalary=salary-pension-Incometax; } else if(salary>=600) { Incometax=8%*salary; pension=4%*salary; Netsalary=salary-pension-Incometax; } else if(salary>=150) { Incometax=5%*salary; Netsalary=salary-pension-Incometax; } else { Incometax=0; Netsalary=salary; } }
klimi
I replaced all my raw pointers with shared_ptr's and I'm using only make_shared, but something strange is happening... After all variables going out of scoped, I'm having 84 constructor calls (expected), but only 14 destructor calls https://pastebin.com/Zh7Yv9YL
I think you have cyclic dependency. I don't think its a good idea to just replace all raw pointers with shared ptr. You will be losing performance and of you are not careful, make cyclic dependency
Pavel
I replaced all my raw pointers with shared_ptr's and I'm using only make_shared, but something strange is happening... After all variables going out of scoped, I'm having 84 constructor calls (expected), but only 14 destructor calls https://pastebin.com/Zh7Yv9YL
+1 to klimi shared_ptr should be used to represent shared ownership (when multiple places control lifetime of an object). If you don't have shared ownership it's better to default to unique_ptr. Also shared_ptr can be constructed from moved unique_ptr, so if you need shared ownership later (e.g. you making a factory and don't know how the created objects will be used), then unique_ptr is a good default also
Anonymous
Mybundlehost Team ️
Have I done something wrong?
Mybundlehost Team ️
Okay, if my post is not recommended please let me know
Anonymous
Mybundlehost Team ️
it's advertising + off-topic
I notice programmer are I here, so I decided to bring our company brand over here, my apologies please if I have violated any rules
Mybundlehost Team ️
Okay noted, hope I could post more of this ?
Mybundlehost Team ️
But besides my company is registered we don't post irrelevant things
Anonymous
But besides my company is registered we don't post irrelevant things
May be reading the rules once again comes handy give it a try
Msd
Answer ?
It's working fine ?
İbn
void print1 (char m, int x); void print2 (int y); void main () { print1('x' ,3); xprint1(char x, int x) } void print1(char m, int x) { if(x>1) { print1(m ,x--); cout<<m<<x; print2 (x); } } void print2(int x) { if (x>=0) { cout<<x; print1 ('A' , --x); } else cout<<"B"; }
Talula
What is the output ?
Compile online and check
Anonymous
It's working fine ?
No it doesn't work I wanna to know what mistake I made ?
我是大娃
why foreach slower than normal for loop?
Yanwardo Florensius
why foreach slower than normal for loop?
how could you say that it is slower?
我是大娃
test it
我是大娃
use benchmark
Pavel
why foreach slower than normal for loop?
It is slower when without optimizations, because real iterators used
Pavel
When optimizations enabled it should be same in speed
我是大娃
no, I use g++ -O2, not work
我是大娃
same program, one is 14000ns, another is 4000ns
Pavel
no, I use g++ -O2, not work
Do you have a link to some online benchmark by any chance? Like this https://quick-bench.com/
Pavel
Will be interesting to see your case, because when I tested it I haven't seen noticeable differences
我是大娃
no. only one benchmark
我是大娃
lib
Yanwardo Florensius
guys, it's an advanced problem which i have never learned before. I will continue to listen
我是大娃
for (auto _ : state) { for(int i = 0; i < 8; i++) //for(const auto &key : m_vecBranchSecFee) { const auto &key = m_vecBranchSecFee[i];
我是大娃
code like this
SUMIT
how can i learn java online ? is there any free source on youtube .. plzz do rply
Moouuaaddhh
why foreach slower than normal for loop?
Send both loops so we can check
Shao
Maybe it's because there are so many things to deal with. For example, you have too many events. The for loop seems to be a basic loop
我是大娃
Maybe I get it. the complier does some optimizations, such as unroll
itsmanjeet
Hey anybody familiar with linux inotify api I want to set the event-mask for IN_MOVE_TO to trigger after the moving or copying complete But it calling during the copying process causing error: Text file busy and multiple calls for same event untile the copy complete
itsmanjeet
👍 most probably
Hanz
Hello, How can I detect whether a file stream/string stream is open with binary mode?
I'm interested for answers to this question. Especially for file streams. Hopefully someone do have an answer.
I'm interested for answers to this question. Especially for file streams. Hopefully someone do have an answer.
It seems the only difference betweens binary or text is how to translate \n to end of line. So it seems not a good ideal to detect whether a stream is binary or text