Danya🔥
@K11M1 what's wrong?
klimi
Don't like the AI gen, but keep it here as it seem to explain it just fine
Danya🔥
It explained this correctly and clearly. It's a simple question, there couldn't be mistakes. Also, it's the latest GPT-4o model which has great reasoning capabilities and I'm very impressed by it.
In the given code, you have two character arrays and you are concatenating one string to another using strcat. Let's break down what is happening: char got[16] = "Kral \"iyidir\""; // declares an array of 16 characters and initializes it with the string "Kral "iyidir"" char kralis[] = "Heheheha"; // declares an array to hold the string "Heheheha" strcat(got, kralis); // concatenates the string in kralis to the end of got printf("%ld, %s", sizeof(got), got); // prints the size of the array got and its contents 1. Initialization and Concatenation: The array got is initialized with the string "Kral \"iyidir\"". This string is 13 characters long (Kral (5) + \"iyidir\" (8)) plus the null terminator (\0), making it 14 characters in total. When you use strcat(got, kralis), the string "Heheheha" (8 characters + 1 null terminator) is concatenated to the end of got. 2. Array Sizes: - got is declared as char got[16]. It has space for 16 characters, including the null terminator. - kralis is declared and initialized as char kralis[] = "Heheheha". It has space for 9 characters, including the null terminator. 3. Concatenation Result: After concatenation, got will contain "Kral "iyidir"Heheheha". This string is 14 (initial string) + 8 (kralis) = 22 characters long. However, because got was initially declared with a size of 16, it can only store up to 15 characters plus the null terminator. This results in buffer overflow and undefined behavior because you are writing beyond the allocated memory of got. The fact that it runs without an error when got is of size 16 is due to the specifics of how the memory is managed and used in your environment. It is not safe and will likely lead to a crash or other unpredictable behavior. 4. Why it crashes with size 15: When got is changed to char got[15], the buffer size is even smaller. It can only hold 14 characters plus the null terminator. Given that the initial string "Kral \"iyidir\"" is already 14 characters, any attempt to concatenate more characters will immediately overflow the buffer and result in a more likely and immediate crash. Key Points: - Buffer Size: Always ensure that the buffer you are writing to has enough space to accommodate the entire resulting string including the null terminator. - Undefined Behavior: Writing beyond the allocated memory leads to undefined behavior which can manifest differently depending on the environment and specifics of memory layout at runtime. - Safe Practices: Use functions like strncat to avoid buffer overflows and always check the buffer sizes. Corrected Code Example: To avoid such issues, you should allocate enough space or use safe string functions: char got[24] = "Kral \"iyidir\""; // 24 to safely include additional strings char kralis[] = "Heheheha"; strncat(got, kralis, sizeof(got) - strlen(got) - 1); // ensure not to exceed the buffer size printf("%ld, %s", sizeof(got), got); This ensures that got has enough space to hold the entire resulting string, and strncat ensures that the buffer is not overflowed.
then it turns out that 21 letter string can hold in 16 byte of RAM because of pointer pointed to kralis(14 char+ptr+\0). So kralis got printed without storing.
Maybe because of this.Thanks
Lwin
Good morning
Yash
My opinion: Buy a land and become a farmer. IT is doomed.
approved finding job is much harder than finding right crop to harvest :)
Yash
btw guys on daily basis learning c++ and it's libraries take more time that Javascript and it's framworks and stuff ? or vice versa (considering Javascript is used in mods plugins on minecraft that is the reason i wanna learn it)
Yash
I don't think there is an end
ouch but on a basic or "i can make stuff" level needs how much time
Arnold
this room has become just indians saying hello to each other
Pavel
btw guys on daily basis learning c++ and it's libraries take more time that Javascript and it's framworks and stuff ? or vice versa (considering Javascript is used in mods plugins on minecraft that is the reason i wanna learn it)
C++ doesn't have a lot of libraries that you need to know, but the language is complex by itself. JS is less complex, but there are some frameworks to learn. I thought Java is used for modding of Minecraft but not JS.
The
js is more complex in other ways
Js well is complex in the way it's more broken I feel.. if you think the browser framework is complex well cpp frameworks can be much more complex , as there is no limit to the depth or breadth At least in js you are limited in depth ... That's why now I'm liking js it feels like a tree you get to sit under coming from a stormy cpp landscape Ofc opinions wary, and this is a noob's rn
SUPER AGENT
this room has become just indians saying hello to each other
Indians/Asians are great programmers, keep them close they are very resourceful
현우
hI
현우
Are setlocale() and I/o functions like fprintf, scanf.... related?
\Device\NUL
Are setlocale() and I/o functions like fprintf, scanf.... related?
Yes, It may affect the locale of input output
Ali Razaa
Hlo
현우
Yes, It may affect the locale of input output
Thanks. So there's no guarantee?
현우
Then what should I do to change the encoding of I/O?
현우
I can just specify encoding when opening a file in Python but I found it hard to do in C
\Device\NUL
Thanks. So there's no guarantee?
By default it use C Locale
Yash
btw what are time complexity and does different algorithm have different complexity?
Yash
C++ doesn't have a lot of libraries that you need to know, but the language is complex by itself. JS is less complex, but there are some frameworks to learn. I thought Java is used for modding of Minecraft but not JS.
alright understood also can i learn js directly after c++ if i finished that it? or i need to go htmlcssjs or javajs ? and yea java but there properties are in javascripts how they behavior i read it in json editor i can send code here its c group
harmony5 🇺🇳 ⌤
btw what are time complexity and does different algorithm have different complexity?
It's the time an algorithm may take to run depending on the size of the data it's running on. Yes it is different for different algorithms. To learn more, you can check the wikipedia entry for it (algorithmic complexity)
harmony5 🇺🇳 ⌤
If you want to learn js, most probably you'll learn html and css, too. It's almost inevitable.
Pavel
alright understood also can i learn js directly after c++ if i finished that it? or i need to go htmlcssjs or javajs ? and yea java but there properties are in javascripts how they behavior i read it in json editor i can send code here its c group
You don't need C++ to start learning JS. Knowing weird quirks of C++ won't be any help to learn weird quirks of JS since those are very different. You don't need html/css unless you want to do web development.
Sarai
I want to become a back end developer
Yash
ty ty
AL
Can I ask which projects are recommended for beginners to practice?
AL
Is there any tips for filtering suitable projects on GitHub?
Amit
How to re allow socket after calling shutdown(0)
Rose
Welcome alsur! Please read the pinned message 🙂 Click the button below to unmute yourself.
Ya deway
Guys I'm having trouble interpreting the TensorNT 10 inference output. The model I used is yolov8 converted to onnx for tensorNT (via the nvonnxparser library). I load the onnx model into the Neural Network and run the inference through a CUDA stream. I have a properly formatted input buffer and output buffer for the model. when I read the data from the output buffer the data makes no sense, I don't understand what it could be. the only thing I noticed is that when I use cv:resize on my high resolution frames of my screen (which to be compatible with the model must be 640x640) the image when displayed is stretched and not scaled. but I still don't understand why the output data from the buffer is really messed up
Khushi
Hey I need guidance about my course?
Khushi
I am little bit confused
Binary
Hey I need guidance about my course?
Which course you're doing right now?
Rose
Purge complete.
Athanas
L
Eugy
Anyone with structured programming notes?
Pavel
Anyone with structured programming notes?
What do you mean by "programming notes"?
Eugy
What do you mean by "programming notes"?
Introduction to structured programming pdf
Rose
Introduction to structured programming pdf
User Eugy has 1/2 warnings; be careful! Reason: offtop, stupid notes
Rose
That's 2/2 warnings; Algorithm is banned! Reasons: 1: no personal ad 2: ad
Volad Malevich
Hi everyone. Could you help me how to build a test project in VSCode with OpenCV? I get an error in the terminal: 'opencv2/opencv.hpp' file not found, even though I can navigate inside #include <opencv2/opencv.hpp>. It means it finds the path, but doesn't build. macOS Sonoma M1 (arm), installed opencv via brew.
Volad Malevich
#include <opencv2/imgcodecs.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> #include <iostream> using namespace cv; using namespace std; ///////////////// Webcam ////////////////////// int main() { VideoCapture cap(1); Mat img; while (true) { cap.read(img); imshow("Image", img); waitKey(1); } return 0; }
Rose
Reported SG [5682882409] to admins.​​​​​​​​​​​
Thomas
Is there a way to make desktop applications in pure C?
Jose
Is there a way to make desktop applications in pure C?
yes, SDL or Allegro (for example) are meant to be used in C, but is up to you to make them see nice or ugly
Hi all.How good is QTelegramBotAPI for bot developing? They introduced this library nowadays for C++.
can you send a link please?
It should be in core.telegram.org/bots/samples
Look for C++, the first in C++ category
Pouya
For programming embedded systems, how much programming knowledge is required?
Pouya
The more the better
a person who is junior how much knowledge should have
klimi
a person who is junior how much knowledge should have
I am afraid i don't understand your question
Pouya
Tree fiddy
Now I realize that I need to prioritize improving my English skills first😢😂
Pouya
I am afraid i don't understand your question
What knowledge should a junior-level person have to be an embedded systems programmer?
klimi
What knowledge should a junior-level person have to be an embedded systems programmer?
Hm... that's an interesting question. I think it mostly depends on the job you are applying, but you should have some general knowledge about electronics, MCU structure. But I don't think junior position requires much deep knowledge. But again I wouldn't aim just to be "junior level"
harmony5 🇺🇳 ⌤
It's just that knowledge is hard to quantify, so that question you're asking may not have an objective answer
Pouya
Your english seems good
Thanks to AI😂 as a listener I have a high level of understanding but when it comes to speaking I need to pause and think.
TimeLow
You can practice with aib
Vladimir
Hi there. I am doing multiprocess console application and using a shared memory for communication between processes. I am trying to figure out how to create a class instance over memory buffer with data. May be placement new or reinterpret cast? I have a simple structure struct Buffer{ char[100] data; int32_t length; } One process writes that Buffer to shred memory and other process reads. How can I build Butter in second process?
Ighor
Look for C++, the first in C++ category
looks like not maintained well, updated   5 months ago