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

2
votes
0answers
10 views

Tetris code for pieces and map

I'm making a simple Tetris clone and would like to know how's my code for the map and pieces. I'm using x, y, ...
3
votes
0answers
24 views

Is this timer efficient?

I found myself writing code to run at a specified frequency more than once, so I decided to make this simple timer. My main concern is that this is not the most efficient way of doing this since with ...
2
votes
1answer
30 views

Implementation of the undef function

Write a function undef that will remove a name and a definition from the maintained by lookup and ...
5
votes
2answers
75 views

Detect optimized

I've been trying to optimize this piece of code: ...
4
votes
2answers
145 views

Optimization for histogram computation algorithm in C

Next is an algorithm to calculate the histogram for a given YUV420sp image. The YUV data is given by the hardware camera as an unsigned char*. The algorithms ...
0
votes
1answer
43 views

Why is this code giving me a wrong answer? [on hold]

I have solved this problem in C, but I get wrong answer every time, could you maybe tell me what I did wrong? Also, don't laugh at my code, I started learning C 7 days ago :) ...
0
votes
0answers
21 views

Solving sudoku in C [on hold]

After hearing about backtracking , i wrote this piece of code to solve sudoku , but it seems to give wrong solutions , what exactly i am doing wrong here ? ...
3
votes
1answer
27 views

Cleaning up repeated calls to NSMakeRange()

In Objective-C, many of the NSString or NSMutableString methods for comparing or manipulating strings require a range argument--that is, an argument of data type ...
9
votes
6answers
839 views

Binary search use in simple guessing game

I'm making a simple guessing game in C. Basically what I need is some help double-checking my work, more specifically a verification that the my binary search in my case statements look okay. The goal ...
0
votes
0answers
8 views

Confused about unsigned in C [migrated]

#include <stdio.h> #include <stdlib.h> int main(void) { unsigned int i; i = -12; printf("%d\n" , i); system("pause"); return 0; } ...
12
votes
3answers
590 views

C Makefile boilerplate

This is the current Makefile that I use with my C projects. Here is what I would like to be reviewed: Reusability - is this Makefile easy to use for multiple separate projects with minimal ...
-2
votes
0answers
46 views

Does anyone know how to solve this problem? [closed]

I already solved this but my program is too slow, I would like to see someone else's code if possible. It can be any language, but C, Python and Pascal prefered.
11
votes
4answers
242 views

Least significant digit (LSD) radix sort of strings

I am learning string algorithms and wrote this C example based on a Java example I found online. Any feedback relating to style, code clarity, whether it is generic enough to be re-used, interface, ...
10
votes
1answer
83 views

Set of wrapper functions for POSIX signal APIs on Linux

Please feel free to comment on the accuracy/validity of the following wrapper source for processing signals using the new POSIX sigaction API. If you feel I'm doing anything wrong or potentially ...
5
votes
2answers
435 views

Windows keylogger in C

I have had this keylogger code for a while now (a few years*), and I figured I would put it up for review. Here is what I would like reviewed (in order): Portability - right now, this program can ...
6
votes
2answers
114 views
6
votes
3answers
323 views

Stack implementation using an array

I am trying a stack implementation using an array. I want to know if this approach is OK or if there is a logical problem. This program is working fine. ...
1
vote
2answers
82 views

Adding very large arrays

I am writing a stochastic simulation for a Yule process: If you start with a certain number of bins each containing a random number of balls, you add another ball to an existing bin with a ...
5
votes
2answers
202 views

Conditional jump or move depends on uninitialised value

Please review the following code: ...
1
vote
2answers
50 views

Capture and assign portions of char array to a struct

I am formally a PHP/C# developer and I am new to C. I need you to help to correct my coding with C. I have a kind of following pieces of HTTP user data string. ...
4
votes
1answer
70 views

My HangMan Game

I have been trying to learn C by making a Hangman game. It's not perfect, but with C, I worry that my coding practices will not be very good. I'm also new to allocating memory myself, so I feel I ...
0
votes
0answers
8 views

Replace floating point math with integer in sigmoid transfer function [migrated]

I would like to replace floating point math in these function without losing much precision, because I have no FPU. Is this possible? ...
9
votes
1answer
142 views

Bubble Sort in C: Array vs Linked List

A few weeks ago I posted a code review of a linked list so I decided to implement bubble sort on my journey of learning C. Here is the referenced linked list library, though this isn't really what's ...
4
votes
2answers
80 views

Matrix falling effect

How can I make this matrix effect more like the matrix movie? ...
4
votes
2answers
76 views

Different factorial algorithm implementations and measuring their execution time

I'm new to C, and as an exercise I'm building 4 different factorial algorithm implementations and measuring their running time. I'm looking for this feedback, especially: The implementation of the ...
4
votes
0answers
37 views

Does this simple memory pool use too much memory?

I just wrote this pool to avoid calling malloc and free when I have some code that frequently allocates and deallocates chunks ...
5
votes
2answers
45 views

VLC media player watchdog daemon v6

This question is a follow-up to a previous version of this program, which I wrote because I found it annoying that VLC Media Player (which I love) prevents the screensaver from starting after playback ...
10
votes
2answers
379 views

Averaging numbers from a file, obeying Single Responsibility Principle

Task: Given comma_separated.txt file with string: 1,2,3,4,5,6,7,8,9,10,11,12...,n - calculate the average value. For example: 1,2,3 should be equal 2 (float) ...
4
votes
2answers
104 views

Implementation of atoi()

I implemented the atoi() function! Here is my code: ...
11
votes
2answers
775 views

First prime number larger than given integer

How can I test this C program for "efficiency"? The most interesting usage is that it returns negative output for large enough input, otherwise the behavior is about expected. Will you suggest how to ...
4
votes
1answer
90 views

How to implement 'cat' command using c?

A 'cat' command. The options are as follows: ...
3
votes
2answers
27 views

Evaluating a polynomial at a given value of x and n

To solve a polynomial equation I have written following program, is there any way to optimize this program. Following code is working code: Program takes input n,x where n is the deg of polynomial ...
7
votes
2answers
74 views

Dictionary brute force on DES encrypted passwords

For a school project I am tasked to decrypt DES passwords. I have sample code provided below and I want to know if this is the best method. Also should I code in error handling for the dictionary ...
2
votes
3answers
212 views

Coding style preference if (aPtr), if (aPtr != NULL), or if (NULL != aPtr) [closed]

I understand that as far as the compiler is concerned, the following lines are equivalent. if (aPtr) {...} if (aPtr != NULL) {...} if (NULL != aPtr) {...} ...
14
votes
5answers
922 views

Setting and getting bits in C

I am just starting to get my feet wet with C; and am rather enjoying myself in doing so. This is sort of a follow up to my last question here. I am posting this ordinate to hopefully getting some ...
5
votes
3answers
119 views

Evaluating a polynomial

You are given a polynomial of degree n. The polynomial is of the form P(x) = an · xn + an-1 · xn-1 + … + a0 where the ai‘s are the coefficients. Given an integer x, write a ...
5
votes
2answers
65 views

Genomic Range Query

Recently I worked on one of the Codility Training - Genomic Range Query (please refer to one of the evaluation report for the detail of this training). The proper approach for this question is using ...
12
votes
3answers
145 views

Credit card verification: string conversion most optimal?

Below is some code which verifies a credit card number using the checksum as well as check if number of digits are appropriate as well if digits start with right numbers. I am not sure if converting ...
10
votes
2answers
163 views

Counting occurrences of values in C Array (Shannon Entropy)

I have written the following C code for calculating the Shannon Entropy of a distribution of 8-bit ints. But obviously this is very inefficient for small arrays and won't work with say 32-bit ...
6
votes
1answer
78 views

Byte Stream implementation in C

This is byte stream implementation in C. It's usage and purpose should be evident from main. Implementation is not finished, this is just start, but comments are still welcome. .h: ...
4
votes
1answer
103 views

Enumerating a boolean in C

This is one way to make a boolean in C. typedef enum { false = 1 == 0, true = 0 == 0 } bool; Recently I made some like ...
9
votes
1answer
74 views

Gauss-Seidal implementation

The code is an implementation of the Gauss–Seidel method. I would like a general review of the code. PS: I use code::blocks IDE ...
9
votes
2answers
86 views

Printing permutations of a given string

I want some feedback on the program I developed in C for printing the permutations of a given string. ...
4
votes
1answer
60 views

Creating a list using a struct in C

I just got into structs and I decided to create a list using them: ...
4
votes
2answers
58 views

Implement strtod parsing

In this comment the OP wrote, I am a newbie so i would like to know how would i parse the negetive numbers/arguments ? In this answer @200_success showed an implementation using the strtod ...
9
votes
3answers
182 views

Parsing comma-separated floats and semicolon-delimited commands

I wrote a cstring parser. It has to work with a relatively wide amount of arguments (usually 3 or 4, but maybe in future with a different amount), which are ...
7
votes
3answers
489 views

Does my reversal program in C follow the common practices?

I sometimes hear people say how they can distinguish between good and bad coders of a certain programming language or even programming in general simply by looking at the code they write. I'm ...
8
votes
4answers
183 views

Dynamic array of structs in C

Based on some code on internet, I implemented a dynamic array of structures in C. I am really interested in some feedback on this. Maybe there are some places where it can cause memory leaks or ...