Anonymous
when i write your second code on visual studio ,i get error in (ranges:: and format::) what's wrong ? i use GNU g++17
You need to use a C++20 compiler. Try -std=c++20 or -std=c++2a as a command line option with g++ to see if it works
Anonymous
when i write your second code on visual studio ,i get error in (ranges:: and format::) what's wrong ? i use GNU g++17
std::format from C++20 is currently only supported in microsoft's standard library (and it doesn't have a function to directly output to an ostream), fmt requires fmtlib
Anonymous
okay ,but in the codeforces, can i use this code in any problems ?
probably not. those were just examples for "alternatives to using namespace std"
Anonymous
i need pdf to learn html please help🙏
Anonymous
okay ,but in the codeforces, can i use this code in any problems ?
Codeforces is just an online platform. It depends on the compiler they use at the backend. So if their compiler supports the C++20 standard, (by default) then it should be able to build it.
Anonymous
Hi
Anonymous
i want to learn c programming from basic
Anonymous
Iie
Anonymous
I also want
Anonymous
How to learn
Hanz
maybe stay in this group
Hanz
would give a sufficient understanding for C/C++
Mehmet Akif
Does anyone have the C code for solar energy electiricty production simulation
Anonymous
#Puzzle #include <future> #include <atomic> std::atomic<int*> p {nullptr}; void f(){ p.store(new int{0}); } void g(){ while(!p.load()); } int main(){ std::async(std::launch::async, g); std::async(std::launch::async, f); } Why doesn't this program terminate?
Alieya MIN
hai guys i want your help
Alieya MIN
why this program give the wrong value?
Anonymous
can you delete this message, post the code either on wandbox.org or godbolt.org, and then share a link?
Ludovic 'Archivist'
It is the attribute of god
Anonymous
Hint: the std::async() function template is marked [[nodiscard]] in C++20. Why?
Let us see if people can figure out why that is a problem.
Anonymous
Message it to one of the admins or to one of us. We will post it here for you.
Ludovic 'Archivist'
True
That reminds me I need to add an optional sanitizer to my version of optional
Anonymous
sorry but how i can share the link?..
Ctrl+F on the website, search "Share"
Anonymous
for godbolt it's on the top right, for wandbox it's on the middle, above outputs (need to click "Run" once for it to show up)
Anonymous
That reminds me I need to add an optional sanitizer to my version of optional
Optional and Error values in C++ should be implemented the way Rust does it. We can easily implement something similar with the support available in C++20 but to get it to Rust level will require more support from the standardization committee.
Anonymous
why this program give the wrong value?
Posting Code link on behalf of Alieya https://wandbox.org/permlink/82TzF6hPPfnD3ilo
Anonymous
Posting Code link on behalf of Alieya https://wandbox.org/permlink/82TzF6hPPfnD3ilo
Alieya Your code to convert the variables returns a value. Ideally these functions should take only one input and return an output. Your second input is practically useless because it is not used. Did you mean to pass it by reference and store the return value in it? You have to print the return values to see the output of your conversion functions. Why have you added blocks after the function call? You dont need them. And the call to each of your conversion function should be in a switch case depending on the value the user chose. The options you list should be in a while loop to allow the user to choose one of them. You dont care about the option chosen
Alieya MIN
so i put it..and have semicolon
Anonymous
ouh..i see.i put the blocks after function call because it say error there
You dont need the blocks. You need the semicolon after the function call statement but.
Ludovic 'Archivist'
Do you have a github link? I want to see why you need to reinvent the wheel.
I need to reinvent the wheel because I often work in kernel space
Ludovic 'Archivist'
I need to reinvent the wheel because I often work in kernel space
This means that my lib is actually freestanding C++20
Anonymous
I need to reinvent the wheel because I often work in kernel space
Aah ok. Are you writing your own kernel? Linux has an implementation for most of the kernel data structures you might need in the kernel.
HaiNahi
Any group for finding 3d artist
Ludovic 'Archivist'
Aah ok. Are you writing your own kernel? Linux has an implementation for most of the kernel data structures you might need in the kernel.
Yeah, let's not speak my mind about those implementations and Linux coding style, nor about their portability to other kernels
Ludovic 'Archivist'
Or the GPL 2
Ludovic 'Archivist'
Hahaha.
I apologize but I remember that time when I received death threats for saying that rms was a politician and not a dev
Ludovic 'Archivist'
So the only open source communities I comment deeply about would be the OpenBSD and 9front commus
Ludovic 'Archivist'
Aah ok. Are you writing your own kernel? Linux has an implementation for most of the kernel data structures you might need in the kernel.
If my code is hard to read on the git, blame whatever buggy CSS preprocessor makes the theme go drunk when not connected
Anonymous
I need to reinvent the wheel because I often work in kernel space
Nice. I just checked your vector and flat tree code just to see how exception safe it is. At a superficial level, it looks like you have all the bases covered. I will bookmark it and see if there is something I can contribute to. If yes, I will touch base.
Mar!o
I try to work steadily and test things but I have some basic stuff (mostly, when I need something I implement it)
What exactly are you working on Ludovic? Your own kernel or on the linux kernel?
Ludovic 'Archivist'
What exactly are you working on Ludovic? Your own kernel or on the linux kernel?
Kernel modules for the network file system I am making
Ludovic 'Archivist'
(as well as the similar drivers for Windows)
Ludovic 'Archivist'
Linux kernel or custom?
Linux, OpenBSD and Windows
Mar!o
Linux, OpenBSD and Windows
Interesting 👍👍
Anonymous
#Puzzle #include <future> #include <atomic> std::atomic<int*> p {nullptr}; void f(){ p.store(new int{0}); } void g(){ while(!p.load()); } int main(){ std::async(std::launch::async, g); std::async(std::launch::async, f); } Why doesn't this program terminate?
Ok. The destructor of future waits forever and blocks the main thread. The f thread is never created. Defer the destructor can solve it. Interesting. [[nodiscard]] is useful to prevent these problems.
Murugaa
hello
Murugaa
can we multiply 3 matric together?
Anonymous
can we multiply 3 matric together?
If the dimensions of the 3 matrices are mxn, nxp, pxq then yes.
Murugaa
mxn, nxp, pxq meaning?
Anonymous
mxn, nxp, pxq meaning?
Dimensions of the matrices. m rows n columns and so on
Murugaa
Write a complete C++ program which can multiply three matrices. Your program need to read matrix A , Matrix B, and Matrix C from data file. The size of all the matrices must be at least 3 x 3 Your program must also store the result into result file.
Murugaa
above are the question
Murugaa
im done but i can' do the 3rd matric
Anonymous
You mean you multiplied the first 2 matrices?
Murugaa
#include <iostream> #include <fstream> using namespace std; int main() { // declaring array variables a, b to hold input matrices // declaring array variable mult to hold the result matrix multiplication int a[100][100], b[100][100], mult[100][100]; // declaring variables r1, c1 to hold the dimensions of matrix a // declaring variables r2, c2 to hold the dimensions of matrix b int r1, c1, r2, c2; // creating an instance of ifstream class to read data from file ifstream infile; // open matrix.dat file to read data of matrices a and b infile.open("matrix.dat"); /* check if matrix.dat file is opened correctly or not if there any error while opening file, report the information to user and stop execution of program */ if (!infile) { cout << " Cannot open the input file."; return 0; } // read the dimensions of matrix a from file infile >> r1 >> c1 ; // read r1 x c1 matrix data from file and store it into array a for(int i = 0; i < r1; i++) for(int j = 0; j < c1; j++) infile >> a[i][j]; // display data of matrix a read from file cout << endl << " Data of Matrix A is: " << endl; for(int i = 0; i < r1; ++i) { for(int j = 0; j < c1; ++j) cout << "\t" << a[i][j]; cout << endl; } // read the dimensions of matrix b from file infile >> r2 >> c2 ; // read r2 x c2 matrix data from file and store it into array b for(int i = 0; i < r2; i++) for(int j = 0; j < c2; j++) infile >> b[i][j]; // display data of matrix b read from file cout << endl << " Data of Matrix B is: " << endl; for(int i = 0; i < r2; i++) { for(int j = 0; j < c2; j++) cout << "\t" << b[i][j]; cout << endl; } /* checking whether multiplication of the matrix can be done If number of columns (c1) of matrix a in not equal to number of rows (r2) of matrix b, then then multiplication of matrix cannot be done */ if (c1 != r2) { cout << " Error! Matrix Multiplication cannot performed"; return 0; } // continuing with matrix multiplication // Initializing elements of matrix mult to 0. for(int i = 0; i < r1; i++) for(int j = 0; j < c2; j++) mult[i][j] = 0; // Multiplying matrix a and b and storing in array mult. for(int i = 0; i < r1; i++) for(int j = 0; j < c2; j++) for(int k = 0; k < c1; k++) mult[i][j] += a[i][k] * b[k][j]; // Displaying the result of matrix multiplication cout << endl << " The result of Matrix Multiplication is : " << endl; for(int i = 0; i < r1; i++) { for(int j = 0; j < c2; j++) cout << "\t" << mult[i][j]; cout << endl; } // writing result of matrix multiplication into matrix.res file // creating an instance of ofstream class to write data into file ofstream outfile; // open matrix.res file to write data of matrix mult into file outfile.open("matrix.res"); /* check if matrix.res file is opened correctly or not if there any error while opening file, report the information to user and stop execution of program */ if (!outfile) { cout << " Cannot open the output file."; return 0; } // otherwise, write mult matrix data into file for(int i = 0; i < r1; i++) { for(int j = 0; j < c2; j++) outfile << mult[i][j] << " "; outfile << "\n"; } return 0; }
Murugaa
i got provided the source code can you help me to check?