Questions tagged [c]
C is a general-purpose computer programming language used for operating systems, games, and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.
4,030
questions
1
vote
0
answers
50
views
Makefile for C project
This is a makefile for a project I'm currently working on. I was wondering, if there was a way to write it more concisely, especially concerning tests and libraries. I would like to maintain the ...
2
votes
2
answers
96
views
Generic Dynamic Array Implementation
I wrote a dynamic array implementation in ISO C11 using void pointers. Everything I've implemented works--at least in all my tests--on a 64-bit machine. It has some vague type-checking and resizes ...
3
votes
3
answers
273
views
Eliminating "implicit conversion changes signedness" warning using _Generic
I'm using enum in C to have constants for values that can be bitwise-or'd together, e.g.:
...
6
votes
3
answers
718
views
Finding the Zeckendorf Representation of a Positive Integer (BIO 2023 Q1)
I was practicing question 1a of the British Informatics Olympiad 2023 past paper.
In the Fibonacci sequence each number is generated by adding the previous two numbers in the
sequence. We will start ...
5
votes
1
answer
357
views
String Decryption in C (BIO 2022 Q1)
I was practicing question 1a of the 2022 British Informatics Olympiad past paper.
Each letter in the alphabet can be given a value based on its position in the alphabet, A being 1 through to Z being ...
4
votes
3
answers
635
views
Error handling for singly linked list in C
I have seen many list implementations in C in this site; I know its been asked many times. I need some advice regarding:
Quality of my code, especially my list library.
How to handle errors in main (...
3
votes
1
answer
250
views
Writing a generic makefile for C projects
Directory Structure:
.
├── check.sh
├── GNUmakefile
├── Makefile
└── src
Makefile has these contents:
...
6
votes
3
answers
971
views
Implement Huffman code in C17
I just finished my first coding project. Prior to this I have only made small programs so I'd like some feedback on what to improve on and how I did in general. The whole code is 658 lines long.
The ...
3
votes
0
answers
133
views
Copy a file portably across UNIX and UNIX-like systems with POSIX API (modeled after Boost's copy_file())
Overview:
Following the POSIX API, there are 2 versions of the function: unix_copy_file(), and unix_fcopy_file(). One works with ...
7
votes
2
answers
712
views
Wrappers around write() and read() and a function to copy file permissions
Below follows wrappers around read() and write() that retry when interrupted by a signal (the case where the return value is -1 ...
1
vote
0
answers
39
views
Determining the value of PATH_MAX on UNIX-like systems
Below is the approach taken in the function allocpath() in the book "Advanced Programming in Unix Environment", which I have modified to simply determine ...
3
votes
2
answers
107
views
Get Terminal Size, Enable and Disable Terminal Raw Mode without NCURSES
I searched around and found these 7 ways to determine the width and height of the terminal:
...
6
votes
2
answers
398
views
Family, felon & fuzz River Crossing challenge
I first saw this challenge when a user posted it to SO about two years ago without a shred of code.
The post's plea, "How do I get started?" meant the user's post didn't survive long on that ...
3
votes
1
answer
72
views
A quine that clones itself and runs some more quines
This is a follow-up to: A Quine program in C, where today I received the following suggestion:
Now, write the code so that the binary "clones" itself (makes a replica with an altered ...
9
votes
3
answers
514
views
Form all possible well-formed strings of 'n' nested pairs of 2 types of ASCII brackets
Taking an interest in the challenge presented in this recent Code Review question, I've concocted a C solution (valid as C++, if I'm not mistaken) seeking to reduce both the lines of code and the ...