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

1
vote
0answers
23 views

Vigenere's Cipher in C [on hold]

I spent two days on this, not so much the math, rather char's and int's and converting to get the thing to work. I was ...
3
votes
3answers
38 views

Displaying days of the week for all of 2015

This program is supposed to determine the day of the week for 2015. Could someone tell me how I could shorten my code? ...
3
votes
1answer
34 views

d-ary heap in C

Now I have this d-ary heap data structure. Note that for d = 2 this is a binary heap. The client programmer specifies the value ...
4
votes
1answer
40 views

Unordered (hash) map for C

I am still working on basic data structures for C. Now I came up with a hash map: unordered_map.h: ...
6
votes
2answers
102 views

Number converter between bases

I just wrote a utility program in C that converts numbers of different bases to 'standard' well-known bases (hex, dec, oct, bin). I called it repnum, short for ...
3
votes
1answer
44 views

Ordered map for C using AVL tree

I was in the mood for some data structures and I decided to code up an ordered map using AVL tree. I will post only map.h and ...
6
votes
2answers
94 views

Reverse engineering Darkstone game archives

Reverse engineering old games is something I do every now and then. This time, I took a shot at this old RPG called Darkstone. The bulk of the game's data is stored in archive files with the ...
10
votes
2answers
59 views

Roguelike-ish template game

I have created a simple program that is supposed to be the core of a roguelike game. The program uses ncurses, and all that is supposed to happen is you choose a race and class, then choose an arena. ...
8
votes
2answers
82 views

Calculating longest increasing sub-sequence recursively

I have trouble understanding recursion, so I'm trying to implement algorithms using it. I wrote this code that calculates the length of the longest increasing sub-sequence. How can I improve this? ...
2
votes
1answer
26 views

Menu driven program to represent polynomials as a data structure using arrays

Write a menu-driven program to represent Polynomials as a data structure using arrays and write functions to add, subtract and multiply two polynomials; multiply a polynomial with a constant, ...
-1
votes
0answers
69 views

C library public API types [closed]

I'm evaluating a library whose public API currently looks like this: libengine.h ...
5
votes
1answer
74 views

C implementation of a string

As C does not have a native string type, I decided to try making a similar type. It's not perfect by any means, so I was coming here to see what I could do to ...
4
votes
1answer
53 views

Generic vector implementation in C using macros

I while ago I experimented with macros in C and came up with the idea of implementing a generic vector library using macros. This code uses the non standard typeof ...
5
votes
1answer
60 views

Implementation of Symbol Table in C

Following is my code for implementing basic symbol table in C. Please review my code and tell where I can improve my program. ...
5
votes
2answers
153 views

Finding the order of sorting of an array

I am finding the order of sorting of an array. The code works but can it be made better especially the return values of the function findSortOrder. ...
1
vote
2answers
41 views

Finding difference between adjacent integers in an array - recursive Implementation

I'm trying to do a recursive implementation of the problem mentioned below. The code works, and takes care of a corner case with only 1 element in array (in which case I should return ...
2
votes
3answers
135 views

Printing a text rectangle

I'm starting C as my first language and am just under halfway done the book I'm using. However, I commonly hear about 'bad' programmers and 'bad' code whenever I encounter any sort of programming ...
4
votes
3answers
37 views

Balanced expression checker

This program detects whether an expression is balanced or not. I would like to know how I can make this more efficient. ...
10
votes
0answers
84 views

C SIMD Matrix Multiplication

I recently started toying with SIMD and came up with the following code for matrix multiplication. I would greatly appreciate if someone with more experience with these things could tell me how far ...
1
vote
0answers
34 views

Lock-free ordered singly linked-list behaves unpredictably [closed]

I wrote an algorithm for lock-free singly ordered list, that uses only one pointer mark to function - kind of novelty. However it behaves strangely, that is under more pressure > 20 threads it breaks, ...
12
votes
5answers
996 views

Credit card validation

I started following Harvard's CS50 (Introduction to Computer Science) on edX, and as part of their Hacker edition set 1 was the following assignment: I am supposed to write a program (in C), that ...
5
votes
2answers
61 views

File of words to a linked-list of words

I'd like to get a review for the function build_list() which reads a file containing words (separated by spaces) and returns a linked-list of words: ...
6
votes
3answers
80 views

Comparing three O(n^2) search algorithms in C

I'm currently taking Harvard's CS50 course via EdEx.org, and we're learning about sorting algorithms. More specifically, we're studying bubble, insertion, selection, and merge sorts. Just for kicks ...
5
votes
1answer
27 views

Distribute an array of numbers equally

The user will input two numbers, say 19 and 5. We need to equally divide 19 equally into 5 groups and output the start index and the end index of each group (using zero-based indexes). Example: ...
7
votes
2answers
65 views

Minimum number of coins problem using dynamic programming - follow up

I previously posted a code here. It turns out that the code is not following the correct dynamic programming principles and instead it was based on a greedy approach. Hence, I started again, keeping ...
10
votes
3answers
564 views

Coin Change: Minimum number of coins

Problem: You are given n types of coin denominations of values \$v(1) < v(2) < ... < v(n)\$ (all integers). Assume \$v(1) = 1\$, so you can always make change for any amount of money ...
9
votes
2answers
159 views

Sending an SMS message in C

Recently I've been fiddling with the idea of sending a text message using C. Looking at a few options, I thought that using libcurl to send an SMTP email using TLS for some security would be the best ...
5
votes
5answers
379 views

Shorthand expansion exercise from K & R C (ex 3-3)

I have written a function to take some shorthand input and expand it into the full form, for example a-z0-9 becomes abcd...789. I added protection from buffer overflow exploits (knocks on wood), and ...
11
votes
1answer
58 views

Callback in Linux kernel driver in order to hide device's low-level protocol

I'm am writing a Linux kernel driver for HD44780 LCDs connected via I2C bus. In my last change I tried to decouple low-level code (which talks to the device via I2C) from device's logic (printing ...
7
votes
2answers
56 views

Game of Runes: revised version

I have created a game called Runes in C. It is similar to Chess, but has a bigger board and different pieces. I would like to know how I can improve the code, for example, with user interface ...
7
votes
1answer
46 views

Game of Runes: a similar concept to chess

I have created a game called 'runes' in C. It is similar to Chess, but has a bigger board and different pieces. I would like to know how I can improve the code, for example, by adding proper error ...
2
votes
2answers
63 views

A basic C Shell for Linux

I have written a basic C Shell. It features the builtins cd, programmer, ver and ...
1
vote
0answers
22 views

Calculating OpenGL view matrices

I'd like a little help here calculating the view matrix for OpenGL based on the lookat type function: ...
11
votes
2answers
289 views

Verify that a path doesn't contain . or .. or // and doesn't end with /

This is actually a function from the first commit of the git source code, for the purpose stated in the title: ...
1
vote
0answers
48 views

WIFEXITED combined with WIFSIGNALED redundant?

I am testing the WIFEXITED to see if a child process exited abnormally or normally, according to documentation, it should return non 0 status for a child process that terminated normally. This is my ...
3
votes
2answers
46 views

Classifying lexemes in a given C program

Please review my code and tell where I can improve my program. ...
4
votes
1answer
59 views

UTF-8 encoding/decoding

I have two functions, a collection of possible error codes, and a unit-testing framework. The parsing of a character into its unary prefix and payload is handled by a few named functions and macros ...
3
votes
1answer
49 views

Tic Tac Toe dynamically changing board position and score board position

Here is my game logic: Tic Tac Toe - player Vs player Player A (first player to enter his name) is getting 'O' and is starting Players choose the desired spot to put their sign(X or O) using the ...
12
votes
3answers
744 views

Safe multiplication of two 64-bit signed integers

The function below implements safe multiplication of two 64-bit signed integers, preventing overflow from occurring: ...
9
votes
3answers
492 views

Daemonizer in C

I am aware that the malloc is a potential memory leak, but with an execvp coming, and that never returning. The purpose is to ...
1
vote
1answer
51 views

4D matrix math library for use with OpenGL

I am trying to create a simple library for C to handle OpenGL matrix operations. You can see the vec3fscalar here. ...
1
vote
1answer
54 views

Non-blocking Unix domain socket

I've developed quickly two kinds of socket use: the first with blocking mode and the second with non-blocking mode. The sockets are Unix domain sockets. My problem is that the kernel consume a huge ...
3
votes
2answers
46 views

LZW encoder and decoder

Recently, I reviewed this question about an LZW decoder. In order to properly review that question, I needed to write my own encoder and decoder to be able to test their program. Someone thought it ...
1
vote
1answer
54 views

Brute-force word cracking program using /dev/urandom

I've been having fun with this program and trying to use different methods and such to achieve the fastest possible word cracking program I can come up with. I'm pretty happy with my current program ...
2
votes
4answers
73 views

Find perfect squares between two numbers

The following problem is from codechef.com: Recently Chef become very much interested in perfect squares. We all know Chef and his weird interests. Anyways Chef will be soon writing his ...
7
votes
2answers
90 views

LZW decompressor in C (II)

Here is an update to my previous thread which you can find here. Again, I'd very much appreciate any advice or comments about the structure/logic of the program, style of the code, or reusability of ...
4
votes
1answer
59 views

vector3 math module

I'm writing a little math module in C to handle vectors and matrices. This will be column-major style but right now I've only finished the basics of the vector functions and wanted some feedback on ...
8
votes
1answer
79 views

Snake game for Windows console

I would apreciate any suggestions on how to make my code better and more efficient. ...
11
votes
1answer
435 views

LZW decompressor in C

Here is a simple decompressor in C. I'd very much appreciate any advice or comments about the structure/logic of the program, style of the code, or reusability of the features. I'm a real novice and ...
15
votes
1answer
826 views

Simple webserver in C

My first learning project in C. Looking for general feedback e.g. gotchas, coding standards, formatting, naming etc. I'm here to learn! webserver.h ...