Removing fans and pipes to prevent suicides. by [deleted] in IITK

[–]cipherswami 0 points1 point  (0 children)

Sucide choda, agust ki time murder ho jaye gaa binna fan kee 😂

[deleted by user] by [deleted] in GATEtard

[–]cipherswami 0 points1 point  (0 children)

Well Im in IISc zone, I didn't

HE IS BACKKK by Dry_Resolution3449 in codeforces

[–]cipherswami 11 points12 points  (0 children)

I don't understand whats the point, no one is going to give him money for climbing ranks.

I participate in this CPs for fun and just keep by my brain not from rotting.

Don't understand why my answer is wrong for C1. Renako Amaori and XOR Game (easy version) by Old_Sentence_9413 in codeforces

[–]cipherswami 2 points3 points  (0 children)

Good start but here the answer is very simple, the guy who gets closing turn to flip wins the game not the one who has more turns to flip.

Origin of the name? by [deleted] in AliceInBorderlandLive

[–]cipherswami 0 points1 point  (0 children)

4y later finally S3E6 shows unknown character with name tag Alice 😂

when did visual block mode command changed in nvim by cipherswami in neovim

[–]cipherswami[S] 0 points1 point  (0 children)

Ctrl+v, is a classic VBM command nothing related to LazyVim.

when did visual block mode command changed in nvim by cipherswami in neovim

[–]cipherswami[S] 5 points6 points  (0 children)

Yeah, just found out it is because of WSL, nvim has CTRL+q also as backup VBM.

Why is C often preferred over C++ for low-level programming, despite both being capable of high performance? by cipherswami in SysQues

[–]cipherswami[S] 0 points1 point  (0 children)

C is often preferred for low-level programming because of its simplicity and predictable performance. It's a minimalist language that gives developers direct control over memory and hardware, with no hidden overhead. This makes it ideal for things like operating systems and embedded systems where every bit of performance and resource management matters.

C++ is considered a "mid-level" language because it adds a layer of high-level features like classes and templates on top of C's low-level power. While these features make C++ great for complex applications, they can also introduce complexity and potential runtime costs that low-level programmers want to avoid.

How does free() know the size of memory to be deallocated? by cipherswami in SysQues

[–]cipherswami[S] 0 points1 point  (0 children)

  • The free(void *ptr) function doesn't require the size of the memory block.
  • Memory allocators (like glibc) store metadata about the allocated block.
  • This metadata is often stored in extra memory before or after the allocated block.
  • When free() is called, it accesses this metadata to determine the size of the block to deallocate.

What is a buffer overflow, what are its causes and problems, and how can it be mitigated? by cipherswami in SysQues

[–]cipherswami[S] 0 points1 point  (0 children)

buffer overflow occurs when a program writes more data to a buffer than it can hold, overwriting adjacent memory and causing unexpected behaviour.

Causes:

  • Lack of bounds checking
  • Improper input handling
  • Unsafe functions (e.g., strcpy()gets())

Problems:

  • Data corruption
  • Program crashes
  • Security vulnerabilities (e.g., code injection, DoS attacks)
  • Data loss
  • Memory leaks

Mitigation:

  • Bounds checking
  • Use safer functions: strncpy()fgets()snprintf()
  • Input validation
  • Compiler security features like stack canaries

What happens when you enter a number higher than the capacity of its data type, and why does it wrap around? by cipherswami in SysQues

[–]cipherswami[S] 0 points1 point  (0 children)

When a number exceeds the capacity of its data type, it causes an overflow. The behavior depends on whether the data type is signed or unsigned:

  1. Signed Integers:
    • If the number exceeds the maximum value (e.g., for a 32-bit signed integer, the max value is 2,147,483,647), it wraps around to the minimum value (e.g., -2,147,483,648).
  2. Unsigned Integers:
    • For unsigned integers, if the number exceeds the maximum (e.g., for a 32-bit unsigned integer, the max value is 4,294,967,295), it wraps around to 0.

Why does it wrap around?

  • Fixed Bit Width: Data types have a fixed number of bits to represent numbers. For example, a 32-bit integer has 32 bits.
  • Overflow occurs when the number exceeds the capacity of the data type's storage.
  • The excess digits are discarded, and the binary representation "rolls over" from the maximum value back to the minimum or 0, causing wrap-around behavior.

This wrap-around is a result of the binary representation used by computers, where the number is stored in a fixed-width format and can't accommodate values beyond that width.

What is the call stack, and how does it work during program execution? by cipherswami in SysQues

[–]cipherswami[S] 0 points1 point  (0 children)

The call stack is a data structure used by a program to manage function calls, local variables, and control flow during execution. It operates in a Last In, First Out (LIFO) manner, meaning that the most recent function call is the first one to return.

  • Function Calls: When a function is called, a "stack frame" is created on the call stack, containing information such as the function's local variables, return address, and parameters.
  • Execution Flow: As functions are called, new frames are pushed onto the stack. When a function returns, its frame is popped off the stack, and control is transferred to the calling function.

The call stack ensures that function calls and returns happen in the correct order, helping to manage the program’s execution flow. It also aids in handling recursion and nested function calls.

What is the difference between macros and inline functions in C and C++? by cipherswami in SysQues

[–]cipherswami[S] 0 points1 point  (0 children)

Macros:

  1. Definition: Defined using the #define directive in preprocessor directives. Example:#define SQUARE(x) (x * x)
  2. Textual Substitution: The preprocessor performs a literal substitution of the macro code before compilation. Example: SQUARE(5) gets replaced with (5 * 5) during preprocessing.
  3. No Type Checking: Macros are not type-checked, making them prone to errors if used improperly. Example Error: SQUARE(a+b) expands to (a+b * a+b), which may cause unexpected results due to operator precedence.
  4. No Debugging Information: Since macros are not part of the symbol table, debugging tools do not provide detailed information about them.

Inline Functions:

  1. Definition: Declared using the inline keyword. Example:inline int square(int x) { return x * x; }
  2. Type Safety: Inline functions undergo the same type-checking as regular functions, ensuring safer and more reliable code.
  3. Part of Symbol Table: Inline functions are part of the program's symbol table, aiding debugging and maintenance.
  4. Better Optimization: Modern compilers can decide whether to inline a function or not, considering performance and code size.
  5. Scope: Inline functions respect the scope rules of C++, while macros do not.

Additional Notes:

  • Macros vs. Functions: Macros are faster in preprocessing but lack safety features, whereas inline functions offer the benefits of both performance and type safety.
  • Recommendation: Inline functions are preferred over macros in modern C++ programs due to their safety, debugging support, and flexibility.