Shahar
Suppose you're implementing a TCP-throughput benchmark. How would you measure the times accurately, efficiently and safely?
Кто-то
Can I make tmp == nullptr after deleting smart pointer ? const IwBrep* tmp = brep->getA(); // return a = unique_ptr. getA() - a.get(); brep.reset(nullptr); if (tmp == nullptr) int a = 10;
Артем
Hello guys Is there any article or common way how must correct allocation for struct with union inside must look like?
Msd
Admin please allow me to share a pic I have a doubt it my office lap i can't copy code from it
Danya🔥
Admin please allow me to share a pic I have a doubt it my office lap i can't copy code from it
If your employer forbids you to share code from your office laptop, you should not do it
Msd
If your employer forbids you to share code from your office laptop, you should not do it
That is copied from net mam I forgot the website name that's why I can't copy
Obaid
Can anyone here help me? I have to write code for Atmel a I2C in C language. I have a digital Sensor (I2C)
Anonymous
Hey y'all What professional work are you using c++ for
Somadina.N
Pls I I need a program for that reads a five digit integer from a user and display the sum of the digits in the number ( if the user inputs 123, the program should display 1+2+3=6)
Somadina.N
Give your effort
Just a beginner
Somadina.N
bc does that.
What's bc
Adriano
How bout made it static ?
The problem is that what I needed to do was to subclass a class that depended on the whole world, and made it impossible to isolate it for testing. I'm not looking for unit testing, but I do need to see the output from my code without fiddling with the GUI. Making anything static wouldn't do anything to help in that case. If you're curious to know what I'm talking about, take a look at line 263 here: https://github.com/Aegisub/Aegisub/blob/6f546951b4f004da16ce19ba638bf3eedefb9f31/src/subtitle_format.cpp#L263 What I am doing is creating a new "format" class, like the ones you see listed there (AssSubtitleFormat, AssSubtitleFormat and so on). So my class needs to be instantiated here and its member functions will be called somewhere else. It's a mess.
Adriano
What's bc
The "basic calculator". https://en.wikipedia.org/wiki/Bc_(programming_language)
Anonymous
https://en.m.wikipedia.org/wiki/Leibniz_formula_for_%CF%80 This is the leibniz formula for π, I tried to replicate that with C++, I had put that formula and I am getting a decent precision upto five digits at n,m<= 299999.0 and at least precision of two digits at n,m<=250.0. I want to improve the code for even better results say precision of value of π at lower digits of n,m what do you lads suggest, Here's my code : https://gist.github.com/parsing-error/a50c5986001e9869ccc7715a6debcb2f
Nobody🪲
#include<stdio.h> int main() { int a,b,c; printf("enter three numbers:"); scanf("%d %d %d",&a,&b,&c); if(a>b && a>c) printf("largest number is %d",a); else if(b>a && b>c); printf("largest number is %d",b); else if(c>a && c>b) printf("largest number is %d",c); else if printf("equal"); getch(); }
\Device\NUL
Wow, very efficient code
Nobody🪲
Whats wrong with this code
Nobody🪲
Its not running
\Device\NUL
Its not running
getch is non standard, your branching is also too complicated
Артем
You don't need semicolon after first else if
\Device\NUL
int a, b, c, max; if (a > b) max = a else max = b if (c > max) max = c if (max == a && max == c && max == b) puts("equal"); else printf("largest value is %d\n", max); Should be better
\Device\NUL
if (max < c) max = c
Ah sorry, thanks for correcting
Anonymous
?
touhou
Its is what
Largest number among three given numbers.
\Device\NUL
Its is what
https://t.me/programminginc/449826 this branching code is too complicated
Anonymous
???
Danya🔥
cin >> a >> b >> c; std::array arr{a, b, c}; std::sort(arr.begin(), arr.end()); cout << arr.back();
touhou
https://t.me/programminginc/449826 this branching code is too complicated
Complicated? Are you saying that from human or computer perspective?
touhou
Nailed it
*insert Obama giving medal to himself picture*
\Device\NUL
Nailed it
I usually write own implementation rather than usung STL
\Device\NUL
This is not great :)
I heard sometimes writing own implementation is much faster than using STL
\Device\NUL
Except for the portability, of course i would use STL
\Device\NUL
https://www.ski-epic.com/templates_stl_rant/
Danya🔥
First you write great code in terms of readability and maintainability, then if you're not happy with the performance you measure it and optimize the non efficient parts
Danya🔥
https://www.ski-epic.com/templates_stl_rant/
Really? Almost 20 years old article?
\Device\NUL
Gilded
using namespace std; 😅
where to add this
Dima
old articles and standards are still better than newer ones
\Device\NUL
where to add this
It's just suggestion, made all std namespaces member to global is bad habit.
Danya🔥
im over today but i need it pls say directly correct that code pls
If you don't understand, before coding, read some newbies books
Gilded
i understand now my energy level 0
Gilded
pls correct code directly
Dima
lol
\Device\NUL
i understand now my energy level 0
You declare the function that will return int, instead it returns nothing aka void
Dima
if you gotta write a code, write it yourself
Danya🔥
pls correct code directly
No one is going to do the work for you
Danya🔥
It doesn't work that way
Gilded
No one is going to do the work for you
its 1 line error i thought 😅
\Device\NUL
People will prefer asking in group rather than notice compiler message 😅
\Device\NUL
Notice me programmer-san >//<
\Device\NUL
its 1 line error i thought 😅
Read some articles that explain how to create function
Danya🔥
Idk if it still relevant
If you want to read blogs about C++, you can follow this channel: https://t.me/cpp_aggregator It has great selection of English and Russian C++-related blogs
Danya🔥
C++ standard library sometimes is bad for sure. For example, did you see the locales library of the std? It is such a mess. Or, for example, C++20 Ranges a great in terms of the code readability and API (in other languages it is done better, though) but the build time of code using the Ranges is just horrible
Danya🔥
I just suggest you to follow this simple rule: https://t.me/programminginc/449856
Nobody🪲
getch is non standard, your branching is also too complicated
Im a begginer i dont understand that much🥺 which is more efficient /complicated 🥺
moyo
/complicated
Danya🔥
/blue_text_must_click
Nobody🪲
Can anyone help me to understand this things more easily!! Any recommendations for learning programming in right way!