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

a game loop with fixed fps and fixed updates per second

I read the gaffer article on fix your tilmestep and also dewitters about fixed frame render rate. I agree with both parts, I think choosing a desired frame rate and locking it locking the frame rate ...
4
votes
2answers
51 views

A closed exception system

I am working on yet another toy project that I named SGL (for "Standard Generic Library" since it mimics some features of C++'s STL as well as a few more utilities from the C++ standard library). ...
0
votes
0answers
16 views

C process program is not able to read more than two messages? [on hold]

I have wrote this simple code to learn more about processes. my goal was to fork 4 process A, B, C and D and send message from each one to the parent. When I run my program the parent can only gets ...
4
votes
2answers
48 views

Return from the parent process code or common code

In this program, the parent process creates a child process, then the child executes ls -l. The parent process waits for the child process to complete and then ...
14
votes
6answers
2k views

Tic-Tac-Toe program in about 250 lines

I'm new to C programming and I recently challenged myself to writing a Tic-Tac-Toe program. I found that my code becomes lengthy very quickly with so many if ...
8
votes
3answers
131 views

Function to return last line's length of a string

I am completely re-writing the textbox GUI widget. In order to set the position cursor after the last character in the last line of a text, it is good if you know the exact column of it. So I created ...
2
votes
2answers
50 views

Linked list insertion

I have written the code below for inserting an element at the position specified by the user. I have seen the code in multiple books, and they have always used two pointers in the function that ...
5
votes
4answers
142 views

Implementation of C linked list (Queue) of C strings on mega AVR

I have been working on a mechanism to queue up strings coming into a system via a USART and have implemented it as a singly linked list. I have done my best to profile the code and its memory usage at ...
12
votes
5answers
732 views

Raw Text TCP Client

Yesterday I posted a request for a code review. After reviewing the code and the reviews, and after some sleep, I decided I can do better. In fact I logged on with the intent of deleting the question ...
8
votes
3answers
82 views

Impromptu TCP sender/receiver

Every once in a while I need to get some random computer thing done; so I write something to do it for me. This is one of those. It needed to be able to send text to, and receive text from, a server - ...
3
votes
1answer
47 views

Substring searching with Knuth–Morris–Pratt

My program uses the Knuth–Morris–Pratt algorithm to search for a particular substring in a .txt file and then store it in a binary search tree. Note that ...
8
votes
4answers
853 views

Armstrong numbers in C

I have very little experience with C, so I decided to code a simple numerical program. An Armstrong number with \$N\$ digits is a number that is equal to the sum of its digits to the \$N^{th}\$ ...
6
votes
2answers
138 views

Arduino driver for 7 segment display with bit-shift register

This code counts down from 30 to -999 on a 7-segment 4-digit display; it works but I don't know if it is a good way to do it or if it follows best practices. I want to start writing libraries for ...
12
votes
3answers
86 views

Brainfuck interpreter (with emphasis on robustness)

While writing a review of @MotokoKusanagi's Brainfuck interpreter, I decided to write my own implementation to illustrate a few points. In particular, I'd like it to be robust to malformed programs, ...
5
votes
3answers
163 views

K&R 4-12 recursive converter int to string

The exercise is: Adapt the ideas of printd to write a recursive version of itoa; that is, convert an integer into a string by calling a recursive routine. I wonder if I have correctly ...
3
votes
2answers
66 views

Image processing routines for an image de-noising program

I have written a multi-language software to implement an image denoising algorithm (composed of many sub algorithms) called CANDLE. I have a C program that is part of the software and would like to ...
3
votes
4answers
131 views

Snippet of an easy binary search tree

ALL I want to do is making binary search tree, inputting there from users, and then print out data in each node one by one according to the user's selection (whether he choose to print the data in the ...
4
votes
1answer
55 views

Creating a linked list of strings

Warning: I'm quite new to low-level programming and memory management so please don't mind it when I'm asking incredibly stupid things. I'm working on a project where I need to read all the lines ...
4
votes
3answers
63 views

Fetching filesystem directory listings on a server

I developed a server which takes a directory name then lists files in it and sends this list to a client. And I want that server to work with Telnet. It works but I have some questions on how I can ...
3
votes
2answers
55 views

Test if arithmetic operation will cause undefined behavior

I've written a command line calculator as an exercise to get ready for my upcoming first programming job. The whole program source is around 450 lines of code, which I think is too long for a single ...
5
votes
2answers
79 views

Minimum number of coins to make change

I am new to programming and I am taking CS50 2014 online through iTunes University. This is the change-making problem in Problem Set 1: Write a program that first asks the user how much change is ...
18
votes
3answers
2k views

“The python that ate a calculator”

In a YouTube video I watched, the speaker said it is important to know how to calculate between numbers of different bases; i.e. two, ten, and sixteen. I was then inspired to write a small C program ...
2
votes
3answers
71 views

Algorithm to follow a point

This code basically makes the dot follow a certain point on the screen. It consumes a significant amount of computing time in my game, so I'd like it to be best ...
7
votes
2answers
228 views

Printing the number in large size

Problem Description Receive a 5 digit number and print out in a large size. Sample input 32145 Sample output ...
13
votes
1answer
223 views

Spell Corrector in C

I recently stumbled across this article on how to write a spelling corrector, and figured I'd try to have a go at it in C (mainly because the link at the end of the page for the C code is broken). ...
5
votes
2answers
61 views

Wildcard string search with capture

My goal was to create a function as performant as possible with results being: True/False as to whether wild matches str. ...
6
votes
2answers
62 views

Counting Increasing Subsequences of size K recursive

The original description of the problem can be found here, its input here and its expected output here. The problem: Given a integer sequence a1 ... an (-10000 \$\leq\$ ai \$\leq\$ 10000). ...
-1
votes
3answers
71 views
3
votes
2answers
74 views

Finding the min and max of an array, using a pointer

Modify the maxmin.c program so that the max min function uses a pointer instead of an integer to keep track of the current position in the array. maxmin.c ...
4
votes
3answers
107 views

RFID financial transaction

I have this code below which establishes connection to server (from device). Basically assembles some buffer, sends it to server, gets response, parses and prints it. I would appreciate if someone can ...
-1
votes
3answers
135 views
2
votes
3answers
79 views

Calculating e^x by math.h and by own means

For this program, the user needs to enter an exponent and the program will calculate \$e\$ (Euler's number) to the power of the exponent the user inputs. This is done by two ways: By the math.h ...
4
votes
2answers
53 views

Escape some char in a byte array

I am trying to construct a binary message packet. It needs to escape binary value 0 by appending extra 0 in front of it: ...
3
votes
1answer
38 views

Ordered doubly-linked lock-free list

I'm implementing a lock-free ordered doubly-linked list based on heavily modified paper entitled Split-Ordered Lists: Lock-Free Extensible Hash Tables by ORI SHALEV. My main concern is correctness of ...
5
votes
3answers
296 views

HackerRank “Flowers” challenge

I'm fairly new to C and wanted a general review of this code. It's a solution to this problem. You and your \$K-1\$ friends want to buy \$N\$ flowers. Flower number \$i\$ has cost \$c_i\$. ...
7
votes
1answer
127 views

Searching in a lock-free ordered single-linked list

The code below represents a lock-free ordered single-linked list, and is a modification of the algorithm proposed in this doc. How can I improve speed of searching (lookingup) in the list maintaining ...
0
votes
0answers
59 views

How to speed-up searching in lock-free ordered single-linked list [duplicate]

The code below represents lock-free ordered single-linked list, is a modification of algorithm proposed in this doc : http://people.csail.mit.edu/shanir/publications/Split-Ordered_Lists.pdf. To find ...
5
votes
1answer
50 views

Dynamic length binary data parsing

I am currently writing code for a UART communication in my firmware. I am getting an interrupt every byte received (meaning I don't get a chunk of data, 1 byte at a time but, in the sample below I ...
5
votes
2answers
63 views

Mandelbrot image generator 2.0

I have rewritten my C Mandelbrot set image generator, including many suggestions given in my previous question (see: Mandelbrot image generator), as well as some recomendations by a friend. The total ...
5
votes
2answers
179 views

Showing the contents of a file

This program reads a filename from standard input and then prints its content. Please review: ...
5
votes
2answers
62 views

2D OpenGL tile atlas fragment shader

I am currently using the following glsl code to retrieve separate textures from a tile atlas: ...
1
vote
2answers
63 views

Build a time struct for current time in UTC

I'm learning about time structs. Without assigning either in code or input routines I want the current time. Please help me refactor this, if it should be. This code just tries to make a time struct ...
4
votes
4answers
113 views

Simple calculator in C V2

My last question had a lot of views (over a 1000) so I decided to apply what I learned from the previous question and revamp the program. I learnt a lot from posting that question (functions, how to ...
10
votes
3answers
1k views

Finding the intersection of two sets of integers

I need to pass a programming exam in order to graduate but I'm having a hard time passing it because most of my programs are too slow. Can someone give me some tips on how to make my programs faster ...
3
votes
1answer
48 views

Input data from file, calculating average by a function

I want to thank you guys firstly for your previous comments and feedback. Really appreciate it. I am learning C with school at the moment, but I plan to be "fluent" in C at the end of august of this ...
15
votes
5answers
1k views

Simple calculator in C

I made a very simple calculator in C that allows the user to perform calculations like addition, subtraction, multiplication and division. This is my first C program that I've made outside of my ...
15
votes
2answers
1k views

Can I buff up your file?

Here I have a method for reading the contents of a file into a buffer and returning whether or not it is successful. Here is what I would like reviewed: Speed: Am I reading in the file as fast as ...
-2
votes
1answer
35 views

Reads data from file. calculates on percentage and shows a table [closed]

So this code is not yet completed. The end result has to calculate the average grade by each question. A=1 b=2 etc... and checks if the question is passed or not. this is what I got this far. ...
14
votes
5answers
722 views

Mandelbrot image generator

I have written a C program to generate a PPM (Portable Pixmap) image of the Mandelbrot set. The program implements many things in C I am fairly unfamiliar with (Structures, error handling, use of new ...
3
votes
2answers
631 views

“Find the number” puzzle

A friend gave this puzzle: Find 3 numbers (say, A B C) such that \$ABC+ABC+ABC = CCC\$ ABC means \$((A*100) + (B*10) + C)\$. Also, these 3 digits must be distinct. I wrote a quick code to find ...