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
20 views

Lock-free ordered singly linked-list behaves unpredictably [on hold]

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, ...
6
votes
2answers
111 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
43 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: ...
4
votes
1answer
46 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
22 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
54 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 ...
-1
votes
0answers
16 views

Balanced Expression [on hold]

Below is the code to determine balancing of symbol. If the expression is balanced then print appropriate message ...
10
votes
3answers
525 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 ...
-1
votes
0answers
23 views

Find fewest number of coins to represent value in C [closed]

I know this has been asked a bunch but I'm encountering a bug in my program and, while I think I know why, I don't know how to solve it. Here's the program ...
8
votes
1answer
57 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
369 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 ...
-4
votes
0answers
16 views

Checking for sorted elements [closed]

I have implemented of getting the string as integer input. I want to check whether they are sorted, if so print true, otherwise, print false ...
-4
votes
0answers
15 views

Testing if an integer has been sorted [closed]

This function gets the string as integer input and returns true if it's sorted otherwise it'll return false. ...
10
votes
1answer
54 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
54 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
41 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
54 views

A basic C Shell for Linux

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

Stack Implementation using Arrays [closed]

I am implementing a Stack using an array. I have written the below code and it works fine ...
1
vote
0answers
21 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
280 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
46 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
36 views

Classifying lexemes in a given C program

Please review my code and tell where I can improve my program. ...
4
votes
1answer
52 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 ...
2
votes
0answers
30 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
726 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
476 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
46 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
44 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
43 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
46 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
66 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
84 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
58 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 ...
7
votes
1answer
74 views

Snake game for Windows console

I would apreciate any suggestions on how to make my code better and more efficient. ...
11
votes
1answer
423 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
806 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 ...
0
votes
1answer
51 views

Remove Duplicates from Sorted List — LeetCode Solution in C

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given ...
-2
votes
0answers
12 views

In C return scanf values from function [migrated]

I am trying to write a subfunction in my calculator program to verify the operands. What I'd like the function to do is return the scanf inputs to the main() function. Here is the code I have used for ...
12
votes
1answer
76 views

Compile-time data structure generator

In response to another recent question I mentioned that one mechanism to avoid runtime overhead for creating a data structure was to create it at compile time and use it directly. Since there was ...
25
votes
5answers
1k views

Running Lights - Embedded “Hello World”

I'm getting my feet wet in embedded development, and like all those before me, my first task was to make an LED blink. I went a bit further than that and made a "runner" that lights up each led from 0 ...
7
votes
2answers
220 views

TCP Tunnel in C

I'm completely aware that I'm not using NIO, but this is my first polished C project. All criticism is welcome, if I'm doing something wrong, I want to nip it in the bud before I'm used to it. ...
14
votes
4answers
682 views

checkmate - C spelling corrector 2.0

Since I posted my first version of the spelling corrector here, I've been working on improving it a little in my free time. I've also gone ahead and put the project up on Github so that others can ...
1
vote
3answers
173 views

Confirming existence of lapindromes

The following description is taken from CodeChef.com's Lapindrome problem. Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same ...
-3
votes
1answer
27 views

Read from Serial Port in C++ is unstable [closed]

I have a serial device (RS232) from which I am requesting (binary) data. This interface answers with a sequence of 5 bytes, or 17 bytes when it has some new data. I figured out, that I have to turn ...
3
votes
2answers
61 views

Assessment of client-server program source code

Can you assess source code of my client-server program? I would like to get an advice about design, code security etc. Thank you very much. The program does the following: Show files in ...
2
votes
3answers
148 views

Reading a configuration file

I have written the following C code to parse a configuration file for settings to my program. I denote comments with a # and blank lines are allowed. e.g.: ...
2
votes
1answer
28 views

Chained hash table implementation to store student's information

This is my implementation of a Hash Table to store information about a student. Everything seems to work as expected, but I'd like some feedback on the following: Is my style good? Is it easy to ...
2
votes
1answer
105 views

Bogosort vs bogobogosort [closed]

A question on Stack Overflow had me look up the article on bogosort on Wikipedia. There they describe the bogosort algorithm and the bogobogosort algorithm. They say, about this last algorithm, that: ...
2
votes
2answers
72 views

Find all multiples of a number in given range in reverse order

I have a problem set which requires me to print all the multiples of a number in given range in reverse order. So far I have tried this but not sure it is optimized or not! ...
5
votes
1answer
69 views

Cache aware, Key/value dictionary based on 4-bit(16-slot) Trie (Prefix Tree), with deferred allocation

Deferred allocation is a memory optimizing trick of using the Node** as Node* when there is only one item in the "bucket". Thus ...