zahra
Look at the other error messages to track down where in your code you wrote that mistake
How can I send the errors? Because it is long and cannot be sent in the message
FriedRice
You can learn STL and the algorithm at the same time so you get to know “why STL”.
Rose
User Kishan has 1/2 warnings; be careful! Reason: ad
Rose
Purge complete.
Ludovic 'Archivist'
Does the group look like a ChatGPT prompt ?
Rose
User Devil has 1/2 warnings; be careful! Reason: do your own homework
Ludovic 'Archivist'
I think I warned you already less than 2 minutes ago
Ludovic 'Archivist'
Do you want to be banned?
Ludovic 'Archivist'
No sorry
Then take warnings into consideration, we will not do your homework
Rose
That's 2/2 warnings; Kishan is banned! Reasons: 1: ad 2: ad
AlanCcE
Hi everyone, I'd have a question about macros and debugging. During some projects that I had done in C, I always had thought about how much cool would be to have some "Debug" macro in which I could put some extra code to be compiled in case of some DEBUG flag being defined at the code, I know that it could be done with some simple IFDEF's, but this always looked a little bit too messy to me. Today I took some time to try to create a macro that could satisfy this problem and I got something like this: #define _Debug(code) \ do { \ code \ } while(0) #else #define _Debug(code) #endif A very simple test case can be found here: https://gist.github.com/Anthhon/12e1b0c4923fb330838168f356e554ea I think it works well for what I want, but I'm not sure if there's anything I can do to make it better or if it could have some weird behavior that I'm not seeing. Could someone with more experience with the compiler help me out?
Rose
Purge complete.
Ahmad
Hello everyone, Please I need someone that will guide me more explanation about c programming for beginners, But my question now is Is there any keyword in a c programming that will takes Alpha numeric to declare the variables?
Simple Sorcerer
Hi all. how can i get a pointer to a class function so that i can call it anywhere in the code. i need "C" compatibility. I think the example will make it clear: c++ #include <cstdio> #include <cstdlib> //========================================== //============== C function ================ /* * the function is somewhere very deep * in the code (not in main) */ int fun(auto *fun_ptr){ // ... (*fun_ptr)(/* variables */); // call function => class function // ... } //========================================== //============== C++ class ================= class A{ // ... void fun(/* variables */); // ... }; //========================================== //======= somewhere not in the main ======== int main(int argc, char *argv[]) { // ... A a; auto fun_ptr = &(a.fun); // ... fun(fun_ptr); // ... }
Simple Sorcerer
I need to use a class function as a callback function
Simple Sorcerer
auto => void (*fun_ptr)(....)
Simple Sorcerer
or I need a clue on how to get around it.
Anonymous
If fun() is a member function, there have to be a way to pass an instance of class A. You could write a wrapper function that use a local static variable of A or make it a template like template<A&> .
Kenshin
If fun() is a member function, there have to be a way to pass an instance of class A. You could write a wrapper function that use a local static variable of A or make it a template like template<A&> .
The std library already has several utilities that you should consider before attempting to write your own, https://en.cppreference.com/w/cpp/utility/functional Start with std::function, then consider one of the other utilities if your needs are met by their more specific functionality.
Rose
Purge complete.
Younes
Hi guys Has anyone solved linear programming(LP) problems?(section 29 in CLRS 4th edition) I'm stuck, Can anyone guide me?
Younes
Tell us what you can't do, we'll help you.
Sure, here my github repo: https://github.com/younesious/Simplex/blob/master/simplex.cpp in this file I wrote a program to solve LP problem with simplex method and print table for every iteration and everything is cool and nice. so far so good. but now when we have ">=" or "=" in constraint and we can't find any BV for constraint problem have been started...
Younes
acctually I want write function for convert to standard model and then find BV or generate artifical variable and enter them and corresponding objective function coeffiecnt in the table.... I write this two func: vector<string> initialize_basic_variables(size_t numRows, size_t numCols, const vector<string> &constraintSigns) { vector<string> basicVariables(numRows - 1); for (size_t i = 0; i < basicVariables.size(); ++i) { if(constraintSigns[i] == "<=") { basicVariables[i] = "x" + to_string(numCols - numRows + i); } else if(constraintSigns[i] == ">=") { basicVariables[i] = "-x" + to_string(numCols - numRows + i); } } return basicVariables; } and this one: cpp vector<string> select_basic_variables(const vector<string> &variables, const vector<string> &constraintSigns, const vector<vector<double>> &constraintCoefficients, const vector<double> &objectiveCoefficients) { vector<string> basicVariables; // according to the order of constraints,loop over constraints and if constraintSigns was <= or >=, // we add a variable x(i+1) to our variable and if constraintSigns == '<=' directly add this variable to basic variable // not that i+1 must be continue after variables.size() and exit the loop // now we enter another loop on constraints and check if that in each constraint if there is a variable whose coefficient is one in its constraint and zero in other constraints and objective function coefficient it accepted and can add to BV // If there is a constraint that cannot have any BV. We need to create an artificial variable to which we can add a new x(i+1) variable to corresponded constraint and add it to BV" and name it x(i0 note that i must be one greater than the number of the last constraint } but I need help to complete them and also write function for bigM and two phase method...
Rob
Can someone share with me a pdf which I can use to learn both C and C++
Kenshin
https://www.learncpp.com/
And for an actual C (and other programming domains) pdf, https://beej.us/guide/
Kenshin
Can someone share with me a pdf which I can use to learn both C and C++
The links above having been provided, your intent seems to be to learn both, concurrently. Maybe don't. Start with one, get on your feet running, well enough to contribute to an open source project, then begin learning the other. As much as people relate the two to the point of referring to them as C/C++ sometimes, they both have preferable idioms and idiosyncrasies that will only be a heavier cognitive load than is necessary while learning. Same is true of learning any two or more programming languages in parallel.
Simple Sorcerer
I think we need to start with the C language
I also want to note that in the C language, although it is not convenient everywhere, the code itself asks to be optimized. In C++ you can write the same thing using stl, but you can not significantly screw up the performance
Simple Sorcerer
said of course a very controversial point. but still agree that C code will still be more optimized
Pavel
Oh damn, I've spent more than half an hour figuring out why my getter returns 1 when the value is 2, rebuilding, running memcheck and UBsan, only to discover that I've accidentally made the return value bool. I love C++
Kenshin
I also want to note that in the C language, although it is not convenient everywhere, the code itself asks to be optimized. In C++ you can write the same thing using stl, but you can not significantly screw up the performance
Not necessarily; compilers are rather excellent at optimizing code already, and trying to help them can backfire. Writing code idiomatic to a language is usually good enough cause new compilers, and new standards, are developed to provide direct language support for such idioms. Before any optimization, we need to make sure that profiling tools confirm that indeed we have a performance issue. Remember, premature optimization is the root of all evil.
Ariana
Hello guys. When I try to run my c++ code on vs code I get this error. I don't know why its happening it was just fixed I probably clicked something accidently. "This version of .exe is not compatible with the version of Windows you're running."
Pavel
Hello guys. When I try to run my c++ code on vs code I get this error. I don't know why its happening it was just fixed I probably clicked something accidently. "This version of .exe is not compatible with the version of Windows you're running."
My guess would be that you're compiling to x86 (32 bit) on a platform that doesn't support it (I believe windows 11 doesn't support it anymore). Or the opposite, you're on x86 platform trying to run x64 (64 bit). Or less likely you either run on or build for arm.
Pavel
How can I check it?
First of all, I would check your compiler flags (not sure how to do that in vs code), and see if there's something that forces x86/x64/arm
Ariana
x64 based processor. I checked in the system properties
Pavel
x64 based processor. I checked in the system properties
Good, then you just need to check what you compile for, or force x64 yourself (need to check the docs for the compiler for that)
Pavel
my_file.h
Yes, but how are you running it? I guess you mean that you press a button to compile/run while this file is opened, but the interesting part is what sent to the compiler
Pavel
what is x86? is it 32 bit system? if yes why they call it x86?
To be honest I have no idea (have to Google it every time)
Pavel
ctrl + alt + N
Sure (I never worked in VS code, so I have no idea what it does)
Ariana
Pavel
Technically .h and .cpp are just for the user to separate them logically, you can compile a header or include a cpp file and it will work (don't do that though more than for laughs, bad habits die hard).
BDev
hi
where are you from?
Rose
where are you from?
User BDev has 1/2 warnings; be careful! Reason: offtop
harmony5 🇺🇳 ⌤
what is x86? is it 32 bit system? if yes why they call it x86?
There are different 32bit ISAs. x86 is the name of one developed by intel. The most commonly used 64bit ISA on desktop today is amd64 (because it was amd that developed it) which intel calls x86-64 (they license it from amd).
harmony5 🇺🇳 ⌤
ctrl + alt + N
Check if there is a .vscode folder in your project. There should be a file with a config for the run feature of vscode
Ariana
also i got new error "c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status"
Zain
Anyone knows any good site or YouTube channel to learn C++
Rose
Anyone knows any good site or YouTube channel to learn C++
Please check out this channel - @Resources for information on learning sources for C and C++ (books and videos) and Frequently Asked Questions.
Ya deway
Hi guys, I would like to learn the kernel of the Windows 10 operating system in an advanced way, in particular the management of drivers, processes, threads and kernel modules or in any case everything that goes around it. Do you know of any good ebooks/resources?
Ya deway
By Microsoft?
\Device\NUL
\Device\NUL
Windows Kernel Programming 2nd edition is also good
Ya deway
Seems Cool thanks!
Maxi
Hey guys
Maxi
So am currently new in programming but i want to learn skills and how to be a master can anyone help me?
Amale
Is there someone use vs code for c programming??
Kenshin
So am currently new in programming but i want to learn skills and how to be a master can anyone help me?
Read up online on different programming language and pick one for a field you desire. Thereafter, begin to practice consistently till you're confident enough to contribute to an open source project. Mastery takes about ten or so years of consistent practice and learning, give or take a few.
Ahmed
Hello everyone, I made a simple project with C in vscode.. but i couldn't do the "Makefile" can someone help me with it?
pasta
Can someone look at this please and tell me why this works and doesn't throw the too few arguments exception? It throws the exception if the function is in the same file. https://onlinegdb.com/FpvzR8rcg7