C Language

C is a general-purpose computer programming language used for operating systems, libraries, games and other high performance work. This tag should be used with general questions concerning the C language, as defined in the ISO 9899:2011 standard. If applicable, include a version-specific tag such as c99 or c90 for questions relating to older language standards. C is distinct from C++ and it should not be combined with the C++ tag absent a rational reason.

61 votes
5 answers
2.9K views
What is ":-!!" in C code?

I bumped into this strange macro code in /usr/include/linux/kernel.h: /* Force a compilation error if conditi

avatar
Fabian
0 1 0 9
asked 07 September, 2021
61 votes
6 answers
2.1K views
How are multi-dimensional arrays formatted in memory?

In C, I know I can dynamically allocate a two-dimensional array on the heap using the following code: int** s

avatar
Georgie
0 1 0 9
asked 07 September, 2021
48 votes
1 answers
2.7K views
Function not working on c program selection sort

Why this function is not working here? It's not sorting on output. Suppose if I enter 1 4 2 the output is

avatar
Hildegard
0 1 0 9
asked 07 September, 2021
47 votes
1 answers
1.8K views
C Program can find (via fopen) in gdb but not release (a.out)

Here's a C simple program, that reads a user input for a file location and prints the first line if such

avatar
Wei
0 1 0 9
asked 07 September, 2021
56 votes
1 answers
2K views
How to contain escape sequences in macro definition #?

I am trying to use this macro definition in C: #define STR(x) #x Is it possible to contain some escape sequen

c
avatar
Kristopher
0 1 0 9
asked 07 September, 2021
67 votes
0 answers
1K views
When linked list element is created using calloc, how to delete element in the delete function without causing leaking issue?

My delete function can pass the test 1-5 shown in main() but can't pass test 6. The expected result is me

c
avatar
Roger
0 1 0 9
asked 07 September, 2021
57 votes
1 answers
2K views
fast multiplication of int8 arrays by constants

I wonder if there is a fast way of multiplying int8 arrays, i.e. for(i = 0; i < n; ++i) z[i] = x * y[i]

avatar
Lashawna
0 1 0 9
asked 07 September, 2021
67 votes
2 answers
743 views
Syntax error in printf command in c programming

Just for context, I am a complete beginner at programming and learning C is my first experience at coding. I d

avatar
Basil
0 1 0 9
asked 07 September, 2021
56 votes
0 answers
326 views
popen & poll for output

We are using popen and poll with timeout for reading output from a process. I have a case where we with popen

avatar
Trudy
0 1 0 9
asked 07 September, 2021
55 votes
1 answers
2.5K views
Initializing the string in C; Is the following useful?

I know how to initialize strings in C in two different ways. char str[] = "abcd"; char str[] = {'a'

avatar
Freida
0 1 0 9
asked 07 September, 2021
54 votes
0 answers
1.2K views
How can I write accept function in my library in socket programming?

I am trying to write the code with my own library. I did this for the other functions such as 'bind'

avatar
Sena
0 1 0 9
asked 07 September, 2021
57 votes
1 answers
2.3K views
Using struct variables in functions - Conflicting types

i'm trying to pass struct variables to a function, but i receive: error: conflicting types for 'refe

avatar
Rudolf
0 1 0 9
asked 07 September, 2021
51 votes
1 answers
505 views
GCC: what&apos;s the default value when a symbol is defined on command line?

The following test code shows that a -DMY_FLAG on command line gives the symbol MY_FLAG a non-zero value, acco

avatar
Shanita
0 1 0 9
asked 07 September, 2021
60 votes
0 answers
1.9K views
SCANF probably not reading the correct value

If you enter more than five characters in the "name" field the function giving wrong output,otherwise if the

avatar
Nereida
0 1 0 9
asked 07 September, 2021