Paulo
What I know is a function signature is its name and parameters types. And it's what is important for overload, and it not consider the return type. A declaration is everthing considering the return type, and is something I don't have here
Paulo
Danya🔥
Paulo
Naol D
Greeting everyone! I have a question related to macro in c++. As an example in a header file I defiened a macro named TABLE type of std::map<string, int> with some initial values. So when using this macro in other part of my program could that be a bottleneck for performance and space? I had the idea becuase a macro is replaced by the preprocessor.
Danya🔥
Naol D
Danya🔥
It does not make any sense
Danya🔥
And your assumption, to be honest, is non-sense.
Please do not try optimize just because you think it might be a performance problem
The correct loop for optimization is:
Write code -> Google how to benchmark software -> benchmark software -> find unoptimized functions -> find problems in them and fix
Naol D
imminent
Gilded
ho guys whats use of learning program when chatgpt script can send anything?
Naol D
Hey man what have I done?
Gilded
the offline trained llm for guided programmatic use
Naol D
Danya🔥
Danya🔥
inline is essential here, const is also
Do not use global variables unless they are constants
Danya🔥
Do not use preprocessor for this stuff
Naol D
Okay thanks!
Danya🔥
Okay thanks!
I removed the warning because you're a sane person
Naol D
Danya🔥
Lee Sin
#include<iostream>
using namespace std;
int main()
{
int year = 0,month = 0, yearLeap = 0, days = 0;
cout << "What year is it?\n";
cin >> year ;
cout << "What Month is it?\n";
cin >> month;
//Judge leap year or not
if((year%4 == 0) && (!year%100 == 0) && (year%400 == 0))
{ yearLeap = 1;
cout << "This is a Leap year!\n";
}
else
{ yearLeap = 0;
cout << "This is an ordinary year!\n";
}
//Judge what kind of month
if(month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12)
{ days = 31;
cout << "There are " << days << " Days in that month.";
}
else if(month == 4 or month == 6 or month == 9 or month == 11)
{ days = 30;
cout << "There are " << days << " Days in that month.";
}
else if(yearLeap == 1)
{ days = 29;
}
else
days = 28;
return 0;
}
Lee Sin
Greetings everyone, this is a code I wrote and I have a question.
At the "Judge leap year or not" part, how did the logic test go right when !year%100 ==100 should be a paradox with year%400 ==0
\Device\NUL
Lee Sin
Ya but I heard that leap year is 4n and not 100n, but 400n
Lee Sin
Thank you, but I'm still wondering is this :
if((year%4 == 0) && (!year%100 == 0) && (year%400 == 0))
the same as:
if (year % 400 == 0) yes
else if (year % 100 == 0) no
else if (year % 4 == 0) yes
else no
\Device\NUL
Lee Sin
OK!!!Thank you so much!😆
\Device\NUL
OK!!!Thank you so much!😆
You should check the bigger value first because small value can be factor of the bigger one but not the opposite.
Pippi
Null
The Missing Semester of Your CS Education" is a practical and hands-on computer science class that fills the gaps in traditional CS education. This course covers essential topics often overlooked in standard curriculum, empowering students and programmers to work efficiently and effectively within the computing ecosystem. Topics include mastering the command shell for task automation, harnessing version control for collaboration and problem-solving, optimizing text editing with advanced features, managing remote machines seamlessly, streamlining file searching, data wrangling from the command line, leveraging virtual machines for experimentation, and enhancing security practices online. With 12 engaging lectures and practical exercises, this class equips participants with indispensable skills to excel in the world of computer science and programming.
https://www.youtube.com/@MissingSemester/
\Device\NUL
james
Time to make perfumes: N no. of perfume bottle P.q.r are machines to make distilled and fragrance and another. t1. 12. 13 are times of machine Find the time take to n bottles of perfumes
james
please make this question
Danya🔥
james
Time to make perfumes: N no. of perfume bottle P.q.r are machines to make distilled and fragrance and another. t1. 12. 13 are times of machine Find the time take to n bottles of perfumes
Danya🔥
klimi
p
#include<iostream>
using namespace std;
int main()
{
int a=2;
int y=++a * ++a;
cout<<a<<" "<<y;
}
klimi
Read the rules about allowed languages
Dima
klimi
p
p
Ziky
Why its output is 4 16
Your question explains why you or anyone else should never write code like that which is complicated to understand.
p
Lxjxjxhks
ifstream inputFile("sample_data.csv");
if (!inputFile) {
cerr << "Failed to open sample_data.csv" << endl;
return;
}
string line;
while (getline(inputFile, line)) {
istringstream iss(line);
string token;
while (getline(iss, token, ',')) {
uint8_t pixelValue = stoi(token);
write(pipe_fd, &pixelValue, sizeof(uint8_t));
// Sleep for 'T' milliseconds to emulate the time interval
this_thread::sleep_for(chrono::milliseconds(T));
}
}
inputFile.close();
exit(0);
}
Lxjxjxhks
notice the Lovelys-MacBook-Air:CynLr lovel$in the ouput that is pwd which i do not want in the ouput, any suggestions
Lxjxjxhks
am i doing something wrong in reading the csv file
Lxjxjxhks
// Define the filter window
double filterWindow[] = {0.00025177, 0.008666992, 0.078025818, 0.24130249, 0.343757629, 0.24130249, 0.078025818, 0.008666992, 0.00025177};
int filterSize = sizeof(filterWindow) / sizeof(filterWindow[0]);
vector<uint8_t> buffer(filterSize, 0);
int final_val = 0;
while (true) {
// Read data from the pipe (data generation process)
uint8_t pixelValue;
ssize_t bytesRead = read(pipe_fd, &pixelValue, sizeof(uint8_t));
if (bytesRead == sizeof(uint8_t)) {
// Add the new pixelValue to the buffer
buffer.push_back(pixelValue);
// Check if the buffer has enough data for filtering
if (buffer.size() >= filterSize) {
// Apply the filter
double filteredValue = 0.0;
for (int i = 0; i < filterSize; ++i) {
filteredValue += buffer[i] * filterWindow[i];
}
if (filteredValue > threshold){
final_val = 1;
}
else{
final_val = 0;
}
// Output the filtered value
cout << "Pixel Value: " << static_cast<int>(pixelValue)<< " Filtered Value: " << static_cast<int>(filteredValue) << " Threshold Value: " << final_val << endl ;
// Remove the oldest pixelValue from the buffer
buffer.erase(buffer.begin());
}
}
// Sleep for a while before processing the next batch
this_thread::sleep_for(chrono::milliseconds(1000));
}
}
Lxjxjxhks
this is the function that prints value for further reference
Paulo
HI guys, I had made my whole background using C and C++, and I love this language, when you start realize how everything work, memory and arrays, pointers and other things, is just amaze how you start understand computer and program languages like C++. But In Brazil I had only one job working with C++, most of my Job in the last 5 years are using Java or C#, and my knowledge start become out of date, sometimes I take some task to do using C++, but the are small projects or integrations. I'm studying modern C++ and focus in high performance systems. I had understand what is move semantics and copy, the problem is, when data structure in C++ use them, like.
If I'm using a vector and this vector resize, I know this will internally use move semantics to resize and move the old values, If I use emplace_back and need create specific constructors to be used by emplace_back, or it can just use move semantics and avoid the use of emplace_back. I'm studying and looking for every peace of information, so if anyome can help me sending articles or more source of information. I'll appreciate that.
Paulo
C++ keywords, features, sintaxe and OOP are not a problem for me , I'm trying understand deeply c++ data structures.
GOPA
Here I give some import YouTube and articles for c++ improvement I personally feel c++ is fast and high performance language giving high amount of control at hardware level believe this will help you
GOPA
https://youtube.com/playlist?list=PL1tk5lGm7zvSoZ_u9U_mkI5Bss45bGCyv&si=8qGHlSBfAERbmtds
GOPA
https://youtube.com/playlist?list=PLkEldc5soqvRcoiSViztJy9dlwYoV8S2t&si=y-Zbx9O2IH9ZTWpb
GOPA
https://people.cs.pitt.edu/~xianeizhang/notes/cpp11_mem.html
GOPA
https://hackingcpp.com/cpp/educational_videos.html#retro-compilers
GOPA
https://github.com/RedSkittleFox/cpp-learning-resources/blob/master/README.md#embeding-different-languages-in-c
Danya🔥
GOPA
This is basic but it gives exposure
GOPA
Well I believe, but I may be wrong I am an undergraduate
Paulo
GOPA
Try cppnuts YouTube channel
Danya🔥
Danya🔥
We recommend sticking with the Resources channel
Paulo
Danya🔥
Random YouTube channels, especially Indian ones, are considered harmful by default
GOPA
thanks but i felt he had a great depth in his video after cherno
GOPA
again, something not useful to you may be useful to others