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

List abstraction using array

Below is the list abstraction using array, ...
0
votes
0answers
10 views

Quadratic probing and hashing - search for words in text files

I created a program for a college class. After I got it working, I wanted to improve it. As a beginner, it is probably a mess. Description It uses a HashFunction ...
0
votes
0answers
20 views

Securely Delete All Drive Data

When giving away or selling a PC, one should be careful not to send personal data with it. I'm in such a situation and was using dd if=/dev/urandom of=/dev/sdb bs=8M...
1
vote
3answers
50 views

C strlcat implementation

I have to reproduce some basic functions in C and one of them is strlcat. After reading the man and testing the strlcat from <bsd/string.h> library, I wrote ...
3
votes
1answer
47 views

Red light, green light… kinda

For an assignment I had to create a client and a server that communicate over a well known FIFO. The server is required to use three threads to serve the client, managed by a semaphore. The code was ...
3
votes
1answer
46 views

Win32/C: Notepad wrapper that automatically converts Unix line endings to Windows line endings

At my work we're dealing with a lot of PHP files written by a third-party company and sometimes we want to "quickly look at" these files in Notepad rather than having to open up a full IDE. The ...
3
votes
1answer
47 views

Waiting for input with timeout

When my program begins, I want to allow the user to hit a key to enter debug mode for one of the modules. Many of the solutions (involving alarm(), in particular) ...
-6
votes
0answers
23 views

Linux performance drawback when networking from two pthreads [on hold]

I have a server application that receives requests in one thread and responds in another. I am using thread pools of pthread-s for both receiving and sending. The performance is not that bad, however.....
3
votes
1answer
50 views

Concatenate variable number of strings

I am learning C on my own. This is not an assignment. I am trying to implement a function that takes a variable numbers of strings and concatenate them in a new string. It works, but I feel it is not ...
5
votes
1answer
24 views

Short header file for safe CLI input handling in C

Proper input handling is a pain in the butt in C, so as part of a project of mine, this header is used to handle reoccurring command line input tasks such as input loops, reading lines and tokenizing ...
-1
votes
0answers
25 views

C implementation of singly linked list [closed]

I am beginner in C and in this program trying to implement a singly linked list in C. This implementation includes the following functionality : adding elements to end of list adding an element at ...
1
vote
0answers
27 views

A-Eye: Analysing Eye tracking Data

I'd appreciate your advice. data file: https://drive.google.com/open?id=0B_UEM0TEmA_yeHJBZ0dzbV9Ca2c ...
1
vote
2answers
64 views

Binary search-like algorithm to find local peak

Please help me improve my coding style. ...
4
votes
1answer
28 views

String tokenizing with arbitrary token count in C

I am building a small program for input handling so I can conveniently parse lines and tokenize strings. The token handling works right now but I have to malloc a lot in the main() to make it work. ...
1
vote
1answer
33 views

Select comparison function for sorting based on type information

So I'm working on a patch for the python interpreter where you go through the list and look at the types of the elements and try to use optimized special-case comparison functions that are much ...
5
votes
4answers
110 views

Factorials, loops, break and professional code

The program below correctly calculates factorials, until the limit for an unsigned long long integer is exceeded. My question has to do with loops and exiting ...
0
votes
0answers
18 views

C Simple Database [closed]

This is an assignment from a book that I am follow and I am trying to complete the extra credit part of the assignment which allows for dynamically allocated records. The path that I have chosen for ...
3
votes
2answers
41 views

Config file to struct in C

I have a struct OPTS which contains a few chars and char[]s. I also have a file opts.cnf ...
6
votes
1answer
96 views

Reference Counting in C99

(I created a GitHub repository; there are few improvements as suggested by other users in the comments) As we know, C99 has no garbage collector. To address the problem of manually deallocate objects ...
-1
votes
0answers
13 views

Coding frogger for VBA using DMA, but only displays a white screen. [closed]

Trying to code frogger on the visual boy advance in c with DMA. I honestly don't understand why it won't show my images. Here is my myLib.c file with the drawing functions: ...
4
votes
1answer
64 views

Using bitwise operators with (unsigned long) instead of bitfields

Here is my solution to Programming Exercise 15-7 from Stephen Prata's C Primer Plus, 6th Edition. This problem asks the reader to: 15-7 Write a program with the same behavior as described in ...
7
votes
4answers
112 views

Calculate the number of palindrome numbers in the given ranges

I've written a program that calculates all of the palindrome numbers in the given range, but the code is slightly slower than needed. I've tried to improve algorithmic complexity to the best of my ...
10
votes
3answers
462 views

Counting the number of “on” bits in an int

Here is some code I wrote as a solution to Programming Exercise 15.3 in Stephen Prata's C Primer Plus, 6th Edition. It is probably worth pointing out that the title of the chapter is Bit Fiddling. The ...
1
vote
1answer
58 views

K&R 2.6 Exercise setbits(x,p,n,y) function

Write a function setbits(x,p,n,y) that returns x with the n bits that begin at position <...
5
votes
1answer
706 views

C program circular array rotation

I'm trying to solve a Hackerrank problem where you perform k array[n] rotations, and at the end, ask for ...
5
votes
2answers
178 views

20×20 Game of Life in C

I am new to C, but have experience with Python and R. The following code implements the Game of Life and represents my first finger exercise in C. I would like to have some feedback regarding the ...
6
votes
2answers
375 views

Small part of an INI parser

I know there are probably thousands of INI parser implementations in C. Nevertheless I want to implement one to learn the art of parsing grammar. I just wrote a small piece of the INI parser and ...
4
votes
1answer
42 views

Simple file server for GET requests

I recently made this simple server in C for Linux systems and was wanting to get another set of eyes on it for a review of the design. I am new to socket programming and used a textbook from school to ...
-6
votes
0answers
84 views

Stack in C and Python

I just finished writing Stack in C and Python and I want someone to review it for bad code, missing features and possible improvements. Here is the C code: ...
5
votes
1answer
225 views

Brainfuck compiler with tcc backend

I wrote simple compiler for Brainfuck with tcc backend (dont ask for assembler/assembly code generator!). It's output runs incredibly slow. Even Hello World program takes a LOOONG while to execute. I ...
1
vote
1answer
44 views

Simulating dynamic polymorphism in C

This code snippet is a research attempt to find means for dealing with dynamic polymorphism (in C): two or more related "classes" share a common interface. Here is my best shot: ...
8
votes
3answers
211 views

A program to represent a coin amount using the smallest number of coins

Recently, I was learning about greedy algorithms. One example that was given was an algorithm for exchanging a given money amount using the smallest number of coins. After the lecture, I wrote a C ...
89
votes
17answers
12k views

Disproving Euler proposition by brute force in C

I wrote a little bit of code to brute force disprove the Euler proposition that states: $$a^4 + b^4 + c^4 = d^4$$ has no solution when \$a\$, \$b\$, \$c\$, \$d\$ are positive integers. I'm no ...
3
votes
1answer
62 views

Sum of Absolute Differences algorithm implementation

Those unfamiliar with that algorithm can have a deeper look here, in a few words, there are two arrays where you subtract each element ar1[0][0]-ar2[0][0] and add ...
2
votes
2answers
63 views

IPC using pipes

I have simulated the conversation between a caller and receiver using fork and pipe. The parent process is the receiver and the child process is the caller. Each message is terminated by a newline. ...
3
votes
1answer
40 views

Basic memory pool, alignment, thread safety

Mainly for practicing purposes, I'm trying to implement a simple, yet efficient memory pool. It's basically a linked list that is able to grow, with fixed sized members. Each node has a flag if it's ...
6
votes
2answers
967 views

Very simple stack in C

I'm starting to learn C and thought it would be a good idea to try and implement some data structures. I started with a very simple stack and would like to hear some opinions. Stack.c ...
8
votes
3answers
239 views

Removing multiple slashes from path

I have been trying to write a sample code block to remove multiple backward or forward slashes from a path (e.g. //a//b should be ...
2
votes
2answers
35 views

Inserting into a binary search tree in C

I am in the process of refactoring this simple binary search tree code responsible for adding new values: ...
1
vote
2answers
100 views

Draw a centered circle

I've written this program that, renders a circle in the middle of the screen. It's been written in a very elementary way. Any suggestions on principles or techniques? Or any more optimal or efficient ...
3
votes
1answer
84 views

Convert hex to base64, part 2

Original question Reimplemented solution following JS1's answer. Changed bit string hack to bitwise operations to get the corresponding base64 index values. ...
0
votes
2answers
60 views

Find first non-repetitive character in a string

The original task was to find the first non-repetitive character in a string. Every now and then I read questions here on Code Review and try answering them myself, and as such I stumbled upon this ...
4
votes
1answer
61 views

Convert and print Celsius to Fahrenheit from certain range of values

I just started learning C, and got to the "for loops"—where an exercise is given to convert Celsius to Fahrenheit ( from -50 to 1000 with a step of 20 ), and print the values. I decided to play with ...
5
votes
2answers
55 views

Get a floating point number from a string with a finite state machine

I wanted to restart the big-float project I had paused the moment I suddenly realized that the implementation of the main four rounding modes (which I postponed so long, that I got all of the IEEE-754 ...
1
vote
1answer
39 views

Simple but (hopefully) safe C nodes for data structures

Nodes will be for simply linked lists, circular lists, maybe later on extending them to work with graphs. I'm trying to be as defensive as possible, will this leak memory? It runs perfectly I'm just ...
-1
votes
1answer
37 views

Trying to build a bare metal stack on the stack [closed]

I'm trying to implement a stack data structure, but not on the heap but using the stack. Also not using any Node or Element struct but raw ints. Is this feasible? This is my code (with debug printfs) ...
4
votes
2answers
131 views

Dynamic Array container in macros

The code below is an attempt to mimic std::vector from the C++ standard library in the C language. The implementation is purely macros, in the C99 dialect, and ...
3
votes
1answer
30 views

A telephone book command line program in ANSI C - follow-up 2

(See the previous iteration.) What does this program do? This program gives you a command line interface for managing your personal telephone book. The program supports three actions: Adding a ...
2
votes
1answer
43 views

Multi platform ASCII spinner in C

Okay I've just finished writing a nice tiny C program to have an ASCII spinner (works on Windows and POSIX). I'm quite new to C, so any suggestions would be great. This is designed to be a small ...
1
vote
2answers
152 views

Swap first and last name in C

I took an entire line of input in the form of a string, and tokenized the string into substrings and obtained the first string as the first name and the second as the last name. This program as it ...