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.

learn more… | top users | synonyms

0
votes
1answer
20 views

Phonebook Implementation in C Programming

I have implemented Phonebook in C programming using singly linked list sorted data-structure. This is my first average-major project. Need some reviews. so that I can improve my coding standards . ...
0
votes
2answers
20 views

Should an interrupt call a seperate function?

Here are some stripped down versions of the two different programs I am deciding between. In version one, my state machine is called within the interrupt: ...
0
votes
0answers
21 views

Saturated signed addition

So this a exercise from the book COMPUTERS SYSTEMS A PROGRAMMERS PERSPECTIVE I need to add two signed numbers and in case it overflows or underflows return ...
4
votes
2answers
32 views

Dictionary implementation using hash table in C

I have written the below code which loads the dictionary and checks if the given word is present or not. The implementation is using a hash table with a chained linked list. In regards to the hash ...
8
votes
2answers
189 views

Simple compression reloaded++

As a follow up to my previous question I've improved the code + algorithm. The compression now works the following way: Each character is followed by a length byte. The top 3 bits of that byte denote ...
9
votes
5answers
2k views

Converting a string to an Integer in C

I'm learning C and one of the questions I've been asked is converting a string to an integer. The code I've written supports converting from a string in any base up to 16/hex to an integer. There is ...
1
vote
0answers
20 views

Termios/Xterm line editor for APL interpreter

As an interesting sub-part of an interpreter -- just the Read part of the REPL -- I present my raw-mode line-oriented editor that I intend to use for my APL interpreter. It defines a large ...
3
votes
4answers
84 views

isRotation and isSubstring method

I have written an isRotation function that calls on isSubstring only once(I am allowed to call it only once). I have implemented ...
4
votes
2answers
39 views

Simple string compression reloaded

Inspired by this question I thought I provide my implementation. I tried to go with the spirit of the *nix tool chain - read from stdin and write to stdout. This has the added benefit of making ...
6
votes
2answers
248 views

Hexadecimal command line file viewer

I have been working on a project for several days. It is a command line program for viewing files in hexadecimal. It is usually very fast, but is there any way I could make it more efficient? ...
3
votes
4answers
108 views

Cut excess whitespace from input and print to output

Title is pretty self explanatory, this program just takes in input (not from command line arguments), removes the extra spaces in the input, then prints that to output. ...
3
votes
2answers
156 views

Reverse array in C

I wrote a function to reverse an array. The first argument is an iterable object, the second argument is the size of the array element in bytes, and the third argument is the length of the array. ...
6
votes
1answer
40 views

subset of UNIX Standard tar implementation

Hi every one I recently implemented subset of ustar archiving utility as my first year programming one project and I would like to get it reviewed and if any one have anything to point out .. dir.c ...
8
votes
6answers
835 views

Length of a C string, capped to some maximum

If I have a oneliner in C such as size_t maxSizeOf(const char *s) { return strlen(s) > M_MAX_SIZE ? M_MAX_SIZE : strlen(s); } would it be better to have ...
10
votes
4answers
450 views

Algorithm for simple string compression

I attempted a problem from the Cracking the Coding Interview book. The following input: aabcccaaa should give the following output: ...
6
votes
2answers
37 views

Implementation of the ls command with several options - follow-up 2

I've made more improvements from previous iterations and my own, including: Added the -n flag (print owner and group IDs instead of names) Eliminated some ...
5
votes
1answer
47 views

Dining Philosophers using C11 threads

I wanted to try multithreading out in C, so I did Dining Philosophers using C11 threads with the approach of having one of the philosophers left-handed. Any suggestions? ...
-4
votes
0answers
47 views

Stacks with linked lists in C [closed]

I am trying to do the push operation of a stack as a linked list .. However in the part of the code scan->next = n a segmentation fault is happening .. any help please ? ...
2
votes
2answers
180 views

C program to generate Seed programs from statically defined Befunge code

My program takes static input, and then number crunches for a few hours. I am currently using Macros, but is there a better, more "user friendly" way to do this without losing on performance. I have ...
2
votes
0answers
27 views

Parallel reduction by key implementations

I have an implementation of the reduction approach used in this document. Furthermore, I extended (crudely) this so I can reduce-by-key. In my setup I can assume that a ...
3
votes
2answers
74 views

HashMap or associative arrays in C

I am trying to implement an HashMap in C. I am trying to used a linked list style of interfacing to make adding and removing keys easy and efficient. Searching is ...
6
votes
3answers
537 views

Checking if characters in a string can be rearranged to make a palindrome

Can I please have some advice on optimizing, cleaning up my code, and places where I could save space/time? ...
11
votes
5answers
532 views

isPermutation method

I wrote an isPermute method. Can I get some tips and advice on better coding style? ...
10
votes
3answers
201 views

Check for whether a string contains any duplicate characters

I am a new programmer and I want to know if I'm inheriting the right styles. I don't want to pick up any bad/amateur habits. Any advice would be much appreciated. This is an ...
4
votes
0answers
14 views

Variation of the internal PHP hashtable

I'm working on a PHP extension in an attempt to learn some C. I've implemented a variation of the internal PHP hashtable, which uses a lookup table and a separate bucket table. The lookup table simply ...
3
votes
1answer
133 views

sleep() function [closed]

I wrote a sleep() function in C, but I don't know is it harmless and cross-platform. Here its code: ...
11
votes
2answers
107 views

Using state transitions to filter C comments

This is my second attempt at K&R 1-23, Write a program to remove all comments from a C program. Don't forget to handle quoted strings and character constants properly. C comments don't ...
7
votes
1answer
34 views

Formatted print without the need to specify type matching specifiers using _Generic

This code allows printing in C with a style similar to C++ ostream. By using _Generic() (see ...
9
votes
6answers
419 views

K&R 1-23 Remove all C comments

From K&R exercise 1-23, Write a program to remove all comments from a C program. Don't forget to handle quoted strings and character constants properly. C comments don't nest. My ...
11
votes
2answers
65 views

Implementation of the ls command with several options - follow-up

I've made vast improvements to my previous ls implementation, including: Added new flags: -g (omit owner listing) ...
15
votes
2answers
304 views

K&R 1-21 write an “entab” program

From K&R exercise 1-21, Write a program entab that replaces strings of blanks by the minimum number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. ...
5
votes
2answers
222 views

Linked list in C

I'm trying to get into C, and I was wondering if I messed up regarding correctly implementing a linked list. node.h ...
3
votes
1answer
45 views

Async safe threadpool

I'm trying the write a threadpool that can safely be added inside a signal handler or in code forked by multithreaded code. Are there any corner cases that would cause this code to fail? What could be ...
7
votes
1answer
43 views

Constructing an odd-even mergesort sorting network

I was searching for a non-recursive odd-even mergesort implementation and found this one: Sedgewick R. The resulting sorting network is not an odd-even-merge sort network. When one draws a diagram ...
7
votes
3answers
160 views

Simple Stack Implementation in C

This is my implementation of the stack data type in C language. It is static meaning it does not grow in size. Any suggestions or feedback would be much appreciated. ...
0
votes
1answer
34 views

Server / client desynchronisation of messages [closed]

I'm trying to build a game where a client gets to play against a server in a game of Tic Tac Toe. I've built the game and followed a somehow structured design of how the game is supposed to happen, ...
11
votes
1answer
242 views

Where it all begins: Khronos

This is the main.c file for Khronos, a personal project of mine. This is basically where the whole program is setup, run and then quit. I'll post the short ...
15
votes
3answers
136 views

Implementation of the ls command with several options

As part of a past assignment, I've expanded on this implementation of ls to have more options available, including non-standard ones. It currently supports these ...
5
votes
1answer
52 views

Calculating diagonal difference

I was trying to solve a problem concerning the difference of the diagonal sums of a matrix (using C99): ...
5
votes
1answer
26 views

Initializing static, machine-specific data in C using a compile-time generated header

I'm using some rather old C code (circa 1996, written in K&R style) to do robust geometric computations, available here, for a library I'm trying to write. In order to work properly, this code has ...
13
votes
1answer
110 views

Fast 32x32 bit multiply on ARM M0

I have a time-critical calculation running on an ARM Cortex-M0. This is the fastest 32x32 bit -> 64 bit multiplication that I can come up with. The following C compiles almost 1-1 to assembly ...
11
votes
0answers
97 views

C and CUDA: circular buffer implementation

I have a programme which uses many circular buffers in an identical fashion on a CPU and GPU (C and C/C++ CUDA). I essentially require many queues, however, due to this being run on a GPU, I have ...
6
votes
1answer
34 views

Unicode-capable symbol table (N-way search tree with hash buckets)

As in my previous question, this module is coupled with its own testing framework. As a symbol-table for a Unicode-capable programming language interpreter, I decided to combine the 3 types of ...
7
votes
3answers
62 views

Solving for every variable in a number of physics formulas

I'm working on making an iOS app to solve physics problems and I'm starting by just having it solve basic kinematics problems with the following formulas (I've coded it in C instead of Swift to start ...
4
votes
2answers
90 views

Splitting strings in C

I have created some code to split strings. The code will split the given string by the given delimiter into an array which is inside a struct it returns. I am using ...
6
votes
1answer
30 views

Brainfix to NASM converter written in C (revision 2)

See this post for the previous question. I have made several enhancements to this compiler and language that make it a lot easier to work with, as well as slightly decreasing executable size (if new ...
7
votes
5answers
620 views

XOR encryption program in C

I've written a program that encrypts files (or stdin) with a user-specified key from 1 to 255. This "encryption" is very insecure, but still a bit better than ROT13 ...
8
votes
2answers
147 views

C hack: replace printf to collect output and return complete string by using a line buffer

I have this great C program I'd like to embed into an iOS app. One passes command line arguments to it and the results are printed to stdout via ...
3
votes
3answers
391 views

Integer Palindrome Check in C

This method should check whether a number is a palindrome or not: ...
5
votes
2answers
93 views

Brainf*ck to NASM converter written in C

I have made a very simple Brainfuck to NASM converter, that is usable for practically all programs. It has one trivial optimisation (to subsitute ADD for ...