Category "c"

Removing trailing newline character from fgets() input

I am trying to get some data from the user and send it to another function in gcc. The code is something like this. printf("Enter your Name: "); if (!(fgets(Na

Gauss-seidel method algorithm code giving inf numbers in solution

I'm not sure why I'm getting inf values when plugging in a 3 equation answer, another set of eyes on the equation loop would be useful, when I use a single equa

Stm32 optimization exercise

I am writing a program to turn on leds on a stm 32 board (model KAmeleon-STM32L496ZGT6). I have LEDs 7 6 5 4 3 2 1 0 When I run the program it goes from 0 to 7

problem in using fprintf_s(getting warnings) in c

I'm new in c.I just want to complete my project.a list of student with struct.and one of the option is save data in a file. I using visual studio 2022 and BTW I

Encryption Strategy for Flashing or updating firmware on ARM Cortex M0+

I want to flash a firmware update through CAN, on my ARM Cortex M0+ MCU. I'm using MKV11 microcontroller. How can I secure the firmware, so that, even if the tr

VSCode C/C++ IntelliSense automatic opening brackets

I'm coding in VSCode and while it isn't really necessary, sometimes i would find it useful if auto completion would add an opening bracket when for example auto

VSCode C/C++ IntelliSense automatic opening brackets

I'm coding in VSCode and while it isn't really necessary, sometimes i would find it useful if auto completion would add an opening bracket when for example auto

Can i use interrupts in inline assembly

I want to use interrupts in inline asm but it is not letting me I think my app is this __asm__("movb %ah,9;" "movb %al,0x41;" "movb %bh,0x0;" "movw %cx,0x1;

How to work with Ukrainian (or Russian) letters in C language?

Good day to all)) The task is as follows: "Enter the entered Ukrainian (or Russian) sentences into a singly linked list organized as a queue (only addresses sho

How to install OpenMP on Mac M1?

I am currently studying to become a computer engineer and I need to work with OpenMP. After some research, I'm still having trouble installing it (#include <

Can I use printf in an Android native binary

Let's assume the phone is rooted and arm binaries can be installed. Can I make a console binary using Android Studio with printf output? Is there a step-by-step

C flexible array define with another type instead of malloc

the general usage of flexible array is to use malloc to define the flexible array. I'm trying to explore defining the flexible array with another struct. An exa

Gurobi model Heap has been corrupted

I am using Gurobi (9.0.3) C API to build a LP model and change the constraints to get different objective value. However, sometimes when I run the code, there i

Why is conversion from string constant to 'char*' valid in C but invalid in C++

The C++11 Standard (ISO/IEC 14882:2011) says in § C.1.1: char* p = "abc"; // valid in C, invalid in C++ For the C++ it's OK as a pointer to a String Lit

While building GCC 8.5.0: "error: `CC' has changed since the previous run"

I'm building GCC 8.5.0 on a Devuan Chimaera GNU/Linux system (using GCC 10). I've configured with ./configure --disable-gnat, then ran make. At some point, I ge

Why the unary * operator does not have a constraint "the operand shall not be a pointer to void"?

C2x, 6.5.3.2 Address and indirection operators, Constraints, 2: The operand of the unary * operator shall have pointer type. Why there is no constraint "the o

What is the rationale for "structure with flexible array member shall not be a member of a structure"?

C11, 6.7.2.1 Structure and union specifiers, Constraints, 3 (emphasis added): A structure or union shall not contain a member with incomplete or function type

How to write "#pragma twice" preprocessor in C?

We know there exists #pragma once which prevents source file to be included more than once, but how to make preprocessor (with conditional compilation) which pr

Does the read () system call clear the stdin buffer when it is called after getchar()?

The following output seems to suggest that when read () is called after a getchar() it clears all the stdin. Let's say that I typed "Hello\n" : char buff; int c

How can I build the file in C++ with wiringPi?

I am trying to run an example program from the wiringPi in C++ in Geany software(called blink.cpp) This is the code (I did not do it, I took it directly from t