Category "c"

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

How to free a malloc 2D array in C initialiszed in this way?

I have declared a 2D malloc array like this in C: int** pArray; int i; pArray=(int**)malloc(pRows*sizeof(int*)); for(i=0;i<pRows;i++)

I'm having a problem creating a linked list [duplicate]

#include<stdio.h> #include<stdlib.h> void insert_front(struct node* head, int block_number); void insert_rear(struct node* head,

getchar() keeps returning EOF even after subsequent calls but read() system calls seem to "clear" the stdin. What are the reasons behind this?

char buff[1]; int main() { int c; c = getchar(); printf("%d\n", c); //output -1 c = getchar(); printf("%d\n", c); // output -1 int re

I am trying to add two strings together but getting 3221225477 Error

I am trying to get a number and a repetition number then adding as many numbers as the number of repetition one after the other. But I am getting 3221225477 res

Have to hit enter twice with fgets() in C?

Good Morning, I'm having an issue with some C code where I am forced to hit enter twice each time input is entered if the length of the input is less than the s

Can Valgrind mend memory corruption?

I am testing a C++ program for problems. I am running it under valgrind. I start the program with // valgrind test char * p = (char*)malloc(4);

Register external C library to avoid incorrect diagnostics / treesitter highlighting in neovim

I want to write a C file + get correct diagnostics and tree-sitter syntax highlighting in neovim. Everything works fine, unless I include an external library (i

File reading in C with fgets entering into a never ending loop

I'm attempting to do basic file reading in C with fgets. It should read one line, pass it to the tokeniser function which should split it at every ' ' and add

How to capture names of clicked folders in the right pane of a GtkFileChooserWidget (GTK4)?

My box runs Ubuntu 21.10. I use GTK4, C-language and XML description of the GUI. I am new to GUIs in general, and to GTK4 in particular. The program uses a GtkF

Write a C function GetEvenNumber

For my studies, I have to write a C function GetEvenNumber: parameters: array with n integers + array size; returns tr array which contains even integers from t

File reading with fgetc in C

I have a simple file reading algorithm but it's not returning the values that are in the file. The below is the code. The input txt values are 200 53 65 98 183

Connecting your own header file in C

Project structure: enter image description here When starting the makefile, I get an error: src/main.c:1:10: fatal error: lib/hello.h: No such file or directory

Why the characters in buffer cannot enter a while loop?

why there is no "*" in output? the input is : abcde[enter key] #include<stdio.h> int main(void){ char ch; while ((ch=getchar( ))== 'e') pr

How to check if a string passed as argument is a modifiable string

The question is pretty much in the title. The code void modify_str(char* str){ if(strlen(str) > 5) { str[5] = 'x'; } } Will invoke undef