klimi
What is auto constant?
you mean auto const ?
klimi
Yes
you want compiler to guess the typo for you and you want it to be const
Unk
How can i after read a CSV file, upload that automaticly on Website ? Is that possible with C ?!
小伟
hallo
小伟
i want to learn programming
小伟
no basic
小伟
what i can learn first
Mr
Csv formats are just like this Coulmn1, Row1, Row2 Coulmn2, Row1, Row2 Column3, Row1, Row2 If you paste the text into notepad and save it as csv format then opening into excel you will understand how csv works Comma seperate Values in Rows And Enter change column
Kriss
any resource suggestions for learning DSA?
Francisco
Good morning to y'all. Is it possible to create a complete application using only dev cpp and then linking it to the web?? And if yes what are we gonna use to link the application to the web??
Zahra
Hello. I want to write a program that takes a number from the user and makes the largest and smallest possible number by rearranging the digits; Do you have any idea?
Sylvester Lim
hey guys whats the symbol to send codes in nice format again ?
Sylvester Lim
in telegram chat
klimi
in telegram chat
3x` code and again 3x backtick
Sylvester Lim
Thanks
Anonymous
no
So what's the way then!
\Device\NUL
Thus array parameter isn't exist try void func(int arr[100]){ printf("%zu\n", sizeof(arr));} Will print sizeof pointer
Francisco
Thus array parameter isn't exist try void func(int arr[100]){ printf("%zu\n", sizeof(arr));} Will print sizeof pointer
In fact how can i create a procedure to rearrange a set of numbers in an array in ascending order and displaying them in that order
Anonymous
Konstantin
int myFunc(int a, int b){ ... } int (*pFunc)(int, int) = myFunc; pFunc(c,d);
Konstantin
int (*pFunc)(int, int) - pointer to function which takes 2 int arguments and returns int.
MᏫᎻᎯᎷᎷᎬᎠ
Hey guys Does someone has C++ open source project where I can contribute to? I have an intermediate experience of the language, just want to improve my skills
Antonio
Hello, could you please recommend a good book or udemy course to learn data structures using C++ as code base?
Antonio
Using at least C++17
kww
int main() { int var1; int var2; printf("Enter the width of rectangle: "); scanf("%d", &var1); printf("Enter the height of rectangle: "); scanf("%d", &var2); int perimeter = 2*(var1+var2); int area = var1 * var2; printf("Perimeter of rectangle: %d\n", perimeter); printf("Area of rectangle: %d\n", area); return 0; } This code works fine, but when I move the declaration of the perimeter and area variables to the top of the other variables, I get a bug. (I'm a beginner in C.) Help me, please
kww
Can you post the buggy version of the code?
Enter the width of rectangle: 4 Enter the height of rectangle: 5 Perimeter of rectangle: -26496 Area of rectangle: 0
klimi
Hello, could you please recommend a good book or udemy course to learn data structures using C++ as code base?
Sure! Here are a few options for books and courses that cover data structures using C++: "Data Structures and Algorithms in C++" by Adam Drozdek "Data Structures and Algorithms in C++" by Goodrich, Tamassia, and Mount "Data Structures and Algorithms with Object-Oriented Design Patterns in C++" by Bruno R. Preiss "Introduction to Algorithms" by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein (This book covers data structures and algorithms using C++, but it's a more advanced text) As for courses, you could try Udemy's "Data Structures and Algorithms: Deep Dive Using Java" course. While it doesn't use C++ specifically, the principles covered in the course can be applied to C++ as well. It's also worth mentioning that data structures and algorithms are fairly language-agnostic, so while it's certainly useful to learn them using a specific language like C++, you can also learn them independently of any particular language. This can be helpful because the concepts you learn will be applicable to any language you use in the future.
kww
Are you doing declaration like this? int perimeter;
No, but you mean I have to do like: int perimeter; perimeter = 2*(var1+var2)
Arthur
If you are doing int perimeter = 2*(var1+var2); it means you are using var1 and var2 before reading values into them
Arthur
But what do these numbers -24496 and 0 mean? Why do we get them?
Since var1 and var2 are local, their initial values are not defined and they can contain some waste
Лазиз
Hello everyone! #define my21_isnan(x) __builtin_isnan(x) Can you explain this part of code __builtin_isnan(x)?
alessandro
i'm testing one program, does it has a struct which it has inside one other struct, like https://pastebin.com/urwnvr42
alessandro
if someone reads my code realize does i make control main_node->people == NULL
alessandro
but it results not NULL and i don't know why
Abul
Problem Statement You love binary numbers 0 and 1. Now,You are given a binary string S of size N. Now you need to tell total how many 01 and 10 pair exist in the given string. Note - A binary string is a string which contains only 0 and 1. And you have to consider 01 or 10 as consecutive. Input Format The first line will contain T, the number of test cases. The first line of each test case contains a positive integer N. The second line of each test case contains a string S, consisting only 0 and 1. Constraints 1 <= T <= 100 1 <= N <= 1000 Output Format Print the count of pairs. Sample Input 0 4 12 101011111010 6 101011 3 100 2 10 Sample Output 0 7 4 1 1
Michel
int main() { int var1; int var2; printf("Enter the width of rectangle: "); scanf("%d", &var1); printf("Enter the height of rectangle: "); scanf("%d", &var2); int perimeter = 2*(var1+var2); int area = var1 * var2; printf("Perimeter of rectangle: %d\n", perimeter); printf("Area of rectangle: %d\n", area); return 0; } This code works fine, but when I move the declaration of the perimeter and area variables to the top of the other variables, I get a bug. (I'm a beginner in C.) Help me, please
[The following was generated by GPT chatbot, try it here https://chat.openai.com/chat I don't know if the answer is correct or not, but it helped me with some issues before, might be helpful for you too. ] It is not a bug, but a problem with the way you have declared and used your variables. In the first part of your code, you have declared var1 and var2 as local variables inside the main function. This means that these variables can only be used within the main function and cannot be accessed from outside of it. In the second part of your code, you have moved the declaration of perimeter and area to the top of the other variables. However, because these variables are declared outside of any function, they are considered global variables. This means that they can be accessed from anywhere in your code, including inside the main function. The problem with this is that when you declare a variable with the same name inside a function, it creates a new local variable with the same name that shadows the global variable. This means that the local variable takes precedence over the global variable and the global variable cannot be accessed or modified within the function. To fix this problem, you can either move the declaration of perimeter and area inside the main function, or you can use the extern keyword to explicitly tell the compiler that these variables are global and should be accessed from within the main function. For example: int main() { extern int perimeter; // Declare perimeter as global variable extern int area; // Declare area as global variable int var1; int var2; printf("Enter the width of rectangle: "); scanf("%d", &var1); printf("Enter the height of rectangle: "); scanf("%d", &var2); perimeter = 2*(var1+var2); // Access global variable area = var1 * var2; // Access global variable printf("Perimeter of rectangle: %d\n", perimeter); printf("Area of rectangle: %d\n", area); return 0; } I hope this helps. Let me know if you have any other questions.
alessandro
I'm asking why the box not allocated has a index in memory?
alessandro
In reality it would be NULL but it result something, whatever it's happend I don't know how solve it
M
/warn
kww
[The following was generated by GPT chatbot, try it here https://chat.openai.com/chat I don't know if the answer is correct or not, but it helped me with some issues before, might be helpful for you too. ] It is not a bug, but a problem with the way you have declared and used your variables. In the first part of your code, you have declared var1 and var2 as local variables inside the main function. This means that these variables can only be used within the main function and cannot be accessed from outside of it. In the second part of your code, you have moved the declaration of perimeter and area to the top of the other variables. However, because these variables are declared outside of any function, they are considered global variables. This means that they can be accessed from anywhere in your code, including inside the main function. The problem with this is that when you declare a variable with the same name inside a function, it creates a new local variable with the same name that shadows the global variable. This means that the local variable takes precedence over the global variable and the global variable cannot be accessed or modified within the function. To fix this problem, you can either move the declaration of perimeter and area inside the main function, or you can use the extern keyword to explicitly tell the compiler that these variables are global and should be accessed from within the main function. For example: int main() { extern int perimeter; // Declare perimeter as global variable extern int area; // Declare area as global variable int var1; int var2; printf("Enter the width of rectangle: "); scanf("%d", &var1); printf("Enter the height of rectangle: "); scanf("%d", &var2); perimeter = 2*(var1+var2); // Access global variable area = var1 * var2; // Access global variable printf("Perimeter of rectangle: %d\n", perimeter); printf("Area of rectangle: %d\n", area); return 0; } I hope this helps. Let me know if you have any other questions.
thank you, I appreciate your answer 🙂
alessandro
/warn
What?
M
Does anyone have a E- of computer fundamentals and programming in c by Reema thareja
alessandro
It's a troll
klimi
Not finding online..at google
you mean this https://www.amazon.in/Computer-Fundamentals-Programming-Reema-Thareja/dp/0199463735 ?
Jose
https://github.com/openrazer/openrazer/blob/master/driver/razermouse_driver.c#L4854 When you see Razer open sources their code, but their code was made by fresh grad electronic student and have no idea about software architecture...
Zahra
Hello there, Does anyone know which one is better between CLRS and Sedgewick?
David
please who know how to setup visual studio for c++
lumen
Is there anyway I can detect if the given code is a C++ or python code without getting into ML or NLP?
Zahra
Is there anyway I can detect if the given code is a C++ or python code without getting into ML or NLP?
don't have enough knowledge, but I think my suggestion will be useful for you. For example, you can run it in Visual Studio or Codeblocks, if the code is run it is C++, otherwise it is Python.
#include <iostream> #include <vector> #include <algorithm> int main() { std::vector<int> vec; int in; std::cout << "Enter int num: "; std::cin >> in; std::cout << std::endl; vec.push_back(in); if (in != 0) { do { std::cout << "Enter int num: "; std::cin >> in; std::cout << std::endl; vec.push_back(in); } while (in != 0); } std::reverse(vec.begin(), vec.end()); auto i = std::is_sorted(vec.begin(), vec.end()); if (i) { std::cout << "Sorted"; } else { std::cout << "Not sorted"; } return 0; }
Can anyone fix that?
Jose
what's wrong with it?
A thousand line switch is an indicator of poor code design, maybe?
#include <iostream> using namespace std; int k[] = {9, 4, 3, 2, 1, 0}; // Sonni kiritish) int size = sizeof(k)/sizeof(k[0]); int s = 0; int foo(int k[]) { for (int i =0; i < size-1; i++) { if(k[i] > k[i+1]) { s++; if(s==size-1)return 0; } else { break; } } return 1; } int main() { cout<<"Kamayishi: "; if (foo(k)==0) { cout <<"Ha" ; } else {cout <<"Yo'q'" ;} return 0; }
mj12
A thousand line switch is an indicator of poor code design, maybe?
Why? What's the alternative? creating a ton of data structs for no apparent reason? reading a file? all of those solutions seem far more complex than what they're doing. You just inevitably end up with code like this sometimes, and in most cases, i don't think it's justified to make it more complicated than it already is. How would you write something like this, genuinely interested.
Jose
Why? What's the alternative? creating a ton of data structs for no apparent reason? reading a file? all of those solutions seem far more complex than what they're doing. You just inevitably end up with code like this sometimes, and in most cases, i don't think it's justified to make it more complicated than it already is. How would you write something like this, genuinely interested.
The apparent reason is you design the solution (and redesign it if the original solution is not easy to maintain) instead of simply "don't touch it, because nobody knows the edge cases it will cause". One starting point (there is no correct solutions in software design) is: starting from this point, create a bunch of mocks and tests to ensure the communication functionality is exactly as the original code and use this communications to place another approach. Properties-based development will simplify the testability and maintability of the project. I choose this approach instead of a mega-switch If you can't see what does the code do in less than 10 minutes, throw it away and start from scratch. Separation is the key here. Remember: Explicit instead of implicit is the rule of thumb. Don't expect everybody will understand what did you do. Don't assume nothing about the business model for a newcomer in the project.
Jose
case USB_DEVICE_ID_RAZER_ATHERIS_RECEIVER: case USB_DEVICE_ID_RAZER_BASILISK_X_HYPERSPEED: case USB_DEVICE_ID_RAZER_OROCHI_V2_RECEIVER: case USB_DEVICE_ID_RAZER_OROCHI_V2_BLUETOOTH: case USB_DEVICE_ID_RAZER_PRO_CLICK_RECEIVER: case USB_DEVICE_ID_RAZER_PRO_CLICK_WIRED: case USB_DEVICE_ID_RAZER_DEATHADDER_V2_X_HYPERSPEED: case USB_DEVICE_ID_RAZER_VIPER_V2_PRO_WIRED: case USB_DEVICE_ID_RAZER_VIPER_V2_PRO_WIRELESS: case USB_DEVICE_ID_RAZER_DEATHADDER_V3_PRO_WIRED: case USB_DEVICE_ID_RAZER_DEATHADDER_V3_PRO_WIRELESS: CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_poll_rate); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_dpi); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_dpi_stages); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_charge_level); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_charge_status); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_charge_low_threshold); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_device_idle_time); break; There is no way anybody will understand why all those devices are configured in exactly this way and this other mouse model has this other way to be binded: case USB_DEVICE_ID_RAZER_DEATHADDER_3_5G: CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_dpi); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_poll_rate); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_scroll_led_state); CREATE_DEVICE_FILE(&hdev->dev, &dev_attr_logo_led_state); break; Why are those models so different between them? There is no explanation, just a belief or "this just works, don't ask me". A deeper insight of the code: why create_device_file is exactly there? No questions, just a bunch of commands.
Jose
This is a common antipattern in embedded software development: the "protocol antipattern". The exact approach is done, for example, when you see code made in microcontrollers (Arduino, for example) with SPI or I2C communications. The code says "send 0x5f, send 0xFF, receive 3 bytes and magic! you've received your accelerometer acceleration params". Nobody will understand why don't hide the 0x5f (magic numbers at a glance) and say explicitly "receive the acceleration params". The code magically is not the documentation itself :)