(-__-)
void printCircle(const Circle& c) { cout << "The area of the circle of " << c.getRadius() << " is " << c.getArea() << endl; } Note that this code will not compile if the getRadius() or getArea() function is not defined const.
Roman
Thank you guys for a such extended answer.
Danya🔥
AlanCcE
Hi guys, i'm having some problem with memory leak, i'm using Valgrind to detect some problems in a C program and i already tried to change the code in every way i can think and nothing worked. Also the Valgrind output seems not so approachable and im not understanding, here is the code snippet if someone wants to help me about it https://gist.github.com/Anthhon/971571ebaf6f4a3bfb727cac33ae1da6
Roman
Why did you leave the group?
Thought nobody was interested in my question.
Danya🔥
AlanCcE
There'd be no memory leaks if you used idiomatic C++
Haha indeed, but i'm doing it to learn it's all about the challenge
Anonymous
What thousands of dollars are you talking about?
To attend the standards committee meeting. To be a face in thee room. Only then you are taken seriously. Most of the times, big corporates sponsor one or two of their employees. But for the rest it is not so easy. And feedback from remote places are as good as trash as far as the corresponding WG team is concerned.
ahmet
Can i send link
AlanCcE
What does generate_password return?
A random string with a length defined by the pass_len variable
Pavel
A random string with a length defined by the pass_len variable
Does it allocate it? Or it uses some static buffer? I mean can it be that you supposed to free it
Anonymous
There's actually this feedback loop but not a lot of people use it The idea of such a loop to use compilers with experimental implementations of the new features
No. It is not like Rust. If you have a feedback, you will have to talk to the people who wrote the proposal and make them understand why or what you think should be improved. There are many people who would inundate the proposers with such requests and it is natural for them to ignore a considerable number of these. The WG teams don't scrounge Reddit or Stackoverflow looking for feedback. This is where Rust, Golang, Kotlin and even something like Ruby and Python these days are different.
Anonymous
But now most of the meetings are online
Yes. But those are only the WG meetings. Not the standard meetings. Every year the standards committee meets face to face three times for a full week. If you miss out on these, you can kiss your feedback goodbye. This is where serious work is done. Whatever work was done in WG meetings are accepted or rejected here as is. There is no room for feedback after as the standard is worked on at these meetings.
AlanCcE
Does it allocate it? Or it uses some static buffer? I mean can it be that you supposed to free it
The function looks like this: char *generate_password(...parameters...){ 19 20 char* generated_password = malloc(LENGTH + 1); . . // GENERATES PASSWORD . 26 return generated_password; 27 } I didn't paid attention about the function but i also didn't freed the memory in generated password cause i have to return it, can i free the memory outside the function?
Anonymous
The function looks like this: char *generate_password(...parameters...){ 19 20 char* generated_password = malloc(LENGTH + 1); . . // GENERATES PASSWORD . 26 return generated_password; 27 } I didn't paid attention about the function but i also didn't freed the memory in generated password cause i have to return it, can i free the memory outside the function?
Yes. Typically when you allocate something and pass it out of the function, you are basically passing the ownership of the allocated memory to the caller and the responsibility for freeing it passes to the caller instead. Sometimes Valgrind may flag this as a leaked memory.
Anonymous
His proposal was probably made by someone from the WG committee. There are exceptions. But my point is how many regular developers can offer feedback on a C++ feature to the standards committee directly? Show me how. Has the standards committee adopted a practice for this? Do they have a forum where people can participate? Where should I raise my questions? The process of joining a WG subcommittee itself is a pain. I know this because I have tried many times to join the Networking subcommittee. You must have a CPP Users Group in your country and your nomination must be supported by 2 other members. Preference will be given to those who are referre by members who have attended CppcOn conferences in the past as a presenter. Once this is done, you will have to share a letter from your employer saying you are involved in C++ work on a day to day basis and your work has a positive impact on the organization. If you are a freelancer, a recommendation from one of your clients would suffice. You will then have to spell out how you think you can make a difference to the committee and why they need you. You are either accepted or rejected after all this. Getting accepted into an IVY League college is far easier.
AlanCcE
Yes. Typically when you allocate something and pass it out of the function, you are basically passing the ownership of the allocated memory to the caller and the responsibility for freeing it passes to the caller instead. Sometimes Valgrind may flag this as a leaked memory.
Talking about code readability you think that would be better to free the memory by itself or just to make the 'generate_password' function send the string directly to the string pointer?
Anonymous
I think in Russian WG the process is easier
There is no country based WG. WGs are groups that work on different part of the standards. So your friend must have been accepted into a WG easily or he/she may have had a friend in a WG group where his/her friend recommended that feature. Talk to him/her. Am sure it wasn't as easy as you make it out to be.
Anonymous
https://stdcpp.ru/en/about
Ok my bad. I meant SG all along i.e. Study Group and not Working Group. I meant to say I tried many times to join Networking SG and not Networking WG. WG like you said is a country specific member organization. Getting into a Study Group requires you to be a part of Working Group which is the C++ User group local chapter in your country that I was talking about. The process of joining a Study Group is a pain and the process is exactly as I detailed out in the previous message,. Recommendation from 2 members of your country's Working group preferably those who have been presenters at CppCon. A letter of recommendation from your employer and also an essay in your own words on why you think you fit in.
Anonymous
But valgrind is right and technically it's leaked memory, isn't it. Or you mean sometimes valgrind can miss it?
Well it depends. This boils down to ownership rules and passing ownership around should be a context that a tool like Valgrind should be able to track given that it embeds itself into the application. It should technically flag something as leaked memory only when all the pointers to that memory have gone out of scope. This is how Memory Sanitizers work in modern compilers. Atleast they are getting close to it. Clang is currently working on a Hazard Pointer based solution for the memory sanitizers which would track ownership. But of course none of these solutions can get close to what the Rust compiler does.
-
Hi everyone . Is there a way to use strtok to find a "substring" in a string ?
Anonymous
Hi everyone . Is there a way to use strtok to find a "substring" in a string ?
What? That is not what strtok is for. Finding a substring is an entirely different problem from tokenizing a string.
Anonymous
I know its use.
If you do, why do you want to use it for something that it is not meant to do. It is like asking "Can I use printf statements to accept input from the user"
Anonymous
I thought maybe there's a way to do it by using strtok
Yes there is a way. But it is not right. You can make the delimiter the substring you are searching for. Instead of using strtok, you can use strspn to do this directly as strtok calls strspn anyway or something similar. But the right way to do it would be to use strstr.
Rashid
Hello
Rashid
I need help am beginner of this question
Rashid
Write a c++ program that accept input from number 1 to 100 display the numbers, and gives the output you entered nice numbers
Rashid
So i need help about the above question anyone understand help me
klimi
So i need help about the above question anyone understand help me
thats not a question, that's an assigment
tyoc213
is runtime performance of an app affected by putting more memory in the computer???? I mean it does not only depend on the CPU if the program can be loaded to memory? (like if your program can be loaded to memory totally with 1GB or less adding say 16GB should not make a difference)
tyoc213
yeah, I ask because I saw this performance test and for me it doesnt make sense that just upgrading memory they ran more fast :) (I believe there should be an update of CPU or something behind the scenes if the same program running) https://filia-aleks.medium.com/benchmarking-all-aws-lambda-runtimes-in-2021-cold-start-part-1-e4146fe89385
Null
why my messages are deleted and resent by bot? According to rules several lines of code are ok
The bot have strict filter for new users, and later you are removed from monitoring. As for your messages, Telegram marked some of your words as a links: someDataService.data, that was a trigger for the bot filter
Rocky
Where can i learn C ?
Rocky
is w3schools a good site to learn C ?
𝔖𝔞𝔯𝔬
I watched a lot of cherno’s videos
klimi
Rocky
not great, not terrible
any great ones u know ?
Rocky
cppreference
i will try it
Rocky
any c learning beginners in this group?
Arch
is w3schools a good site to learn C ?
It'll give you only general idea of C programming language topics like pointers, for loops, if's and so on. After you're done with reading the site go for practice resources like w3resources
Arch
You'll also need other resource where you get additional info about a topic, it gives you deeper understanding and you learn other features too
Arch
Well I can't say that but if you have other issues and you can't practice as often as it is needed then very long, maybe a year or longer
Arch
If you are ok with time then maybe a ±month
Arch
Depends on you
Chat Boss
ahmet samir sent a code, it has been re-uploaded as a file
ahmet
https://leetcode.com/problems/longest-common-prefix/solutions/391089/c-easy-to-understand-solution-using-sort/?orderBy=most_votes&languageTags=cpp Can some body explain this
Chat Boss
ahmet samir sent a code, it has been re-uploaded as a file
ahmet
https://t.me/programminginc/490464
Thadeu
how much time does it take to learn c (basics)
1 month if you are a programmer (focus on heap/stack difference, memory allocation and pointers) 4~6 months if not (due to the programming logic concepts you don't have)
Thadeu
any c learning beginners in this group?
Started less than 6 months ago... check my profile link to see the code I've done this time, mostly Lua modules written in C.
Thadeu
@Rafiqshaik07 forget about CPP reference, and other material containing lessons about C++. Some books mixes C and C++ and, even having dedicated/separated chapters about them, it is inevitable that authors end mentioning C++ when speaking about C, making it more difficult than really are.
Thadeu
@Rafiqshaik07 You can start with this guide (online free): https://beej.us/guide/bgc/ A good book to follow is "C: The complete reference" of Herbert Schildt. And again... Most of C harsh is about pointers, memory and difference about stack and heap. Once you master it, the language is a breeze.
AlanCcE
any c learning beginners in this group?
I'm ✋ Started less than 1 and a half month and just now I'm getting a little comfortable with the language, actually working in some small projects Studying all by some books and a lot of Stack Overflow