Emmanuel
Good eve family How can I input and make an audio to play through codeblocks using C? Thank you for your feedback
Dima
try OpenAL
Anonymous
int a=1,b=2,c=3,d; d = ++a || ++b && ++c; cout<<a<<" "<<b<<" "<<c<<" "<<d;
think about the code: a=0; x = a++ + a++ + a++; x may be the 3 or 6. A complier executes like that 1 + 1 + 1. B complier executes like that 1 + 2 + 3;
Pavel
“undefined behavior”
I'm not sure that here is undefined behavior, as far as I remember && and || introduce a sequence point 🤔
Pavel
I don't usually write code like this, but it looks "correct" to me
Anonymous
Don't write code like this. it will increase the complexity of reading.
Pavel
why can you explain
Undefined behavior is a big topic: https://en.wikipedia.org/wiki/Undefined_behavior The thing is, if this code is UB (undefined behavior), then it doesn't matter what the result is, the code is ill-formed. I doubt that it's UB though. People don't want to give you just the answer because you need to understand what you're doing, giving an answer is called spoonfeeding and it doesn't help learning. To get better feedback you also shouldn't ask for an answer, it's better to ask in a way: "There's this code, I think it produces answer [what you think] because [why you think it is the answer], am I correct?". This directly shows that you already tried to solve it yourself and want to learn (and not just want to be spoonfed).
Linav
Hey there, your can recommend ideas for pet projects ?
Pavel
Hey there, your can recommend ideas for pet projects ?
what level do you have? what do you want to learn? how many days/months/years you want to spend on it? :)
SR27
i get it now
SR27
so thank you everyone 👍
Pavel
Junior :3
C or C++? Level I mean how long you're learning C++ :) How about a console chess game? You input moves for each player and it outputs the new state of the board, whether you could make this move, and a result of the game when someone is won. If it's too easy you can make history of moves with undo-redo, an AI for it, graphical interface, or a multiplayer version over TCP (depends on what you want to learn)
Linav
I heard aws and Oracle gives
Anonymous
oh I have a similar project,but it still on plan
Pavel
I think this version of #meta was better
UrCodeBuddy️ 💻
i need a lil help with sorting
UrCodeBuddy️ 💻
can anyone please help me out
UrCodeBuddy️ 💻
the challenge is that i can only use 2 arrays, one the initial and the 2nd one where im printing, and in each iteraation im changing them
Anonymous
int a=1,b=2,c=3,d; d = ++a || ++b && ++c; cout<<a<<" "<<b<<" "<<c<<" "<<d;
It is not Undefined Behavior like others said. This is perfectly defined. As for the output, just run the code and ask doubts if you have any after seeing the output.
Anonymous
Complex{ int r; int i; public: Complex operator+(Complex& c) { Complex t; t.r = this->r + c.r; t.i = this->i + c.i; return t; }}; int main() { Complex c1, c2, c3; c3 = c1 + c2; } If this '+' would have been a function then c3 = c1.+(c2) should be the syntax. I am not able to understand in c3 = c1 + c2 syntax that which object is calling '+' operator & which object is being passed as parameter
Anonymous
Explain please
Anonymous
It is not Undefined Behavior like others said. This is perfectly defined. As for the output, just run the code and ask doubts if you have any after seeing the output.
well I guess it is UB the compiler may choose to compile it anyways it likes increment after comparing or comparing before increment
Pavel
well I guess it is UB the compiler may choose to compile it anyways it likes increment after comparing or comparing before increment
I think in C++17 the order in this case is specified (not sure if was specified before since it should be short-circuit evaluated, so the right-hand side may be not executed in some cases) Note Sequence Point Rules https://en.cppreference.com/w/cpp/language/eval_order
Anonymous
Mobile complier would recognise ASCII value
Anonymous
?
paper
How can I check mingw compiler C++ version? It says on google that you have to type 'g++ --version' but it doesn't print anything about the version of C++
Alviro Iskandar
Mib of MB ?
what do you mean?
Linav
u need server mean rdp,vm?
Oh, but i don't know What uses for chats
Danya🔥
How can I check mingw compiler C++ version? It says on google that you have to type 'g++ --version' but it doesn't print anything about the version of C++
1. C++ doesn't have versions, what it does have is "standards" 2. g++ --version gives the version of the compiler 3. A compiler can support multiple C++ standards. The standard can be set up by -std flag when you compile a program 4. Using mingw in Windows is a terrible idea, you should use clang or msvc
Danya🔥
I have msvc , but in what way is it better than mingw?
MinGW is a buggy sh*t that doesn't support C++ fully
Alviro Iskandar
yes, i understand the meaning of MiB, but in my context the MB a binary multiples, so what I mean is 1MB = 1024*1024 bytes
Anonymous
well I guess it is UB the compiler may choose to compile it anyways it likes increment after comparing or comparing before increment
No. || and && introduce sequence points prior to C++11. And after C++11, evaluation order specifies the same behavior as it was with sequence points before C++11
\Device\NUL
what do you mean?
MiB is 1024 base while MB is 1000 base
Alviro Iskandar
MiB is 1024 base while MB is 1000 base
No, depends on the context
Alviro Iskandar
MiB is 1024 base while MB is 1000 base
It's 1024*1024 tho, not 1024
Ammar
\Device\NUL
It's 1024*1024 tho, not 1024
Sorry, that's KiB and KB
Anonymous
I should go for dsa after completed basics in c
Anonymous
???
后藤
it is reported undefined reference to `opj_read_header' when i compile opencv4.55 on ubuntu
后藤
how to solve it?
后藤
need i install the OpenJepg?
LeBouy
anyone with a link of octave group?
Anonymous
I've read the rules and I agree with them.
Jefferson
Hey guys. To learn Cpp, should I know C language first?
Jefferson
Nice. Do you have any indication of sites, etc, to learn?
klimi
cpprefference
touhou
cpprefference
I wouldn't recommend this site to a newbie to learn cpp. I'd rather recommend a book or learncpp or an online course.
Anonymous
Can anyone help me with the ff Qs Write c++ expression for a=12x Z=5x+14y+6k Y=x^4 C=a^3/b^2k^4 G=h+12/4k
klimi
I wouldn't recommend this site to a newbie to learn cpp. I'd rather recommend a book or learncpp or an online course.
i will recommend this site to begginers, it is the best tool that i can recommend for learning cpp. You want to know what standard functions do? they have you covered even with Examples. Surely you need more than just one source to learn i don't deny that
touhou
i will recommend this site to begginers, it is the best tool that i can recommend for learning cpp. You want to know what standard functions do? they have you covered even with Examples. Surely you need more than just one source to learn i don't deny that
I somewhat agree with you to some extent, but in that message specifically, cppreference is the only source you mentioned. Which to me is a very bad idea, especially for new learners.
klimi
as for me i cannot recommend any other source
Евгений
The best teacher is you. Only you know how to teach yourself. Google will help you with the information
Евгений
It's Chinese said:)) i think it's very useful phrase
Евгений
But I guess the best one is learncpp, those guys often update information
klimi
some guide can be very nice
Muhammad Saqib Ali
Please guide me... How to print last entered number at the top from the linked list?
Anonymous
Please guide me... How to print last entered number at the top from the linked list?
a linked list, we have types of linked list singly or double or circular?
Nana
Hello
Nana
Pls how can I shar my cpp .exe file with friends?
\Device\NUL
Sharing executable isn't allowed because it may contains sussy code
Nana
Just show the code
#include <iostream> #include <vector> #include <ctime> #include <cstdlib> #include <algorithm> using namespace std; void intro(); int main() { intro(); vector<string>names; unsigned seed = time(0); srand(seed); int min = 1, max = 10, num, size = (rand() % (max - min+1))+min; string person_name, search_name; for(int count = 0; count < size; count++) { num = (rand() % (max - min+1))+min; if(num == 1) person_name = "Kofi"; else if(num == 2) person_name = "Ama"; else if(num == 3) person_name = "Abraham"; else if(num == 4) person_name = "Papa"; else if(num == 5) person_name = "Ernest"; else if(num == 6) person_name = "Ibra"; else if(num == 7) person_name = "Opoku"; else if(num == 8) person_name = "Augstine"; else if(num == 9) person_name = "Nana"; else person_name = "Ann"; names.push_back(person_name); } sort(names.begin(), names.end()); cout<<"Enter the name you're searching for: "; cin>>search_name; cout<<endl; if(binary_search(names.begin(), names.end(), search_name)) cout<<"Name is found in the lists\n"; else cout<<"Name is not found in the list\n"; cout<<endl; cout<<"Here are the names\n"; cout<<"------------------------\n"; cout<<endl; cout<<"INDEX\t\tNAMES\n"; cout<<"------------------------------\n"; for(int count = 0; count < names.size(); count++) { cout<<count + 1<<"\t\t"<<names[count]<<endl; } return 0; } void intro() { cout<<endl; cout<<"\t\tThis is a searchable vector program in C++\n"; cout<<"\t\t----------------------------------------------\n"; cout<<endl; }