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
1answer
27 views

Helper utilities for easier benchmarking in C

I have this tiny library for measuring the execution time in milliseconds and returning the duration plus the result: execres.h ...
-2
votes
0answers
15 views

What's wrong with this binary tree code? [on hold]

Apparently my professor gave me bad code, right before the exams. ...
-5
votes
0answers
39 views

This code satisfies 74.0% of test case. help rectify the code [on hold]

Input and Output Format: Input consists of 5 integers that correspond to r1, r2, r3, r4 and x. Output consists of 2 integers. The 1st integer corresponds to the minimal amount she would spend for ...
3
votes
3answers
558 views

C Socket Part-1

In my ongoing attempts to become a better blog writer I have some written some more code that needs reviewing. Full Source: https://github.com/Loki-Astari/Examples/tree/master/Version1 First Article: ...
5
votes
2answers
87 views

Longest palindrome in an array

I am new to programming, and think this code could be improved upon. Any suggestions? ...
-1
votes
1answer
29 views

More error-checking

The purpose of this code is to check for errors in my code for a custom shell. In a previous answer, they say that my code didn't have error-checking. You need to check the result of every ...
8
votes
2answers
61 views

Hash table OOP implementation in C

To brush up my C I decided to do some OOP programming in C. I have never tested this before, but I was curious to try it since seeing an example of it a while ago. I decided to implement a simple hash ...
1
vote
1answer
32 views

Unit test with check testing framework

I have some code where the purpose is the decide if a char is between quotes in an expression. For example, awk '{print $1}' has a ...
11
votes
1answer
77 views

Arduino Snakes and Ladders

Here is a snakes and ladders game I made using an Arduino using a serial terminal, a set of addressable LED's to create a physical game board, a 7 segment display, and a piezoelectric to create sound. ...
1
vote
0answers
24 views

MPI BMP image comparison

I made a simple program in which I compare two images pixel by pixel and determine if the pictures are the same. I'm trying to adapt it to MPI, but I'm afraid that the communications are taking too ...
-4
votes
0answers
20 views

RPN Stack for Real numbers [closed]

Mi problem that I need a scanf(%s) of a 'char', but I don't know where, or how, I have to put it to still work The RPN calculator. Please HELP!!!!!!!! My code takes operands and operators from the ...
-5
votes
0answers
27 views

Tic Tac Toe board [closed]

Hey guys I've been trying to use this function to scan in a tic tac toe board but I get a "too few arguments for format" error message, here's my code : ...
3
votes
2answers
47 views

Extracting the longest line from standard input

I'm reading the K&R book and I'm interested in a program which finds the longest line on the input. I've written the same code as in the book, but I wanted to do it myself. I tried to write my own ...
-3
votes
0answers
19 views

Josephus problem in C using linked list [closed]

// why is temp2 not getting updated? It points to a[0]. ...
-3
votes
0answers
15 views

How can I change my code using SIMD/AVX to calculate ranks in my page rank algorithm? [closed]

I am writing a page rank program. I am writing a method for updating the rankings. I have successful got it working with nested for loops and also a threaded version. However I would like to instead ...
12
votes
1answer
67 views

Platformer in C

GitHub repo. main.c ...
5
votes
2answers
75 views

Thread synchronization with mutex

This program prints odd numbers by thread1 and even numbers by thread2 sequentially. Can this code be optimized or made more ...
6
votes
2answers
84 views

Fast CSV parser

I have written a CSV parser to read in 12609000 lines of CSV data. Each line has 16 fields of both string and double type data. The following code takes about 40 seconds to parse the data. I would ...
1
vote
0answers
36 views

Cuda C Matrix Compression

I am using Cuda to learn and implement a CSR matrix compression algorithm. What can I do better relating to C's best practices? main.c: ...
0
votes
0answers
41 views

Building a Stack with C structs

After reading the book from which this example is from I started using APIs like this ...
3
votes
2answers
56 views

Exercise 1-22 from K and R: line folding

I'm currently learning C with K&R, i'm right now in the exercise 1-22, but it's a little... hard to understand (at least for me). It says: Write a program to "fold" long input lines into two ...
4
votes
3answers
79 views

Merging 3 sorted linked lists

I already know how to merge two linked list, but I needed to code a function that'll merge three already sorted linked lists into one. I wrote a code and it is working fine, it takes care of null ...
2
votes
1answer
89 views

POSIX arithmetic expansion

I understand that a shell should be able to perform arithmetic expansion. My shell can do it: $ echo $((1+2*3+4*5)) 27 My solution uses the lemon parser where I ...
3
votes
1answer
44 views

Two variants of a picture database initialization routine

I wonder which of the two snippets is better? In the second one, I extracted two short subroutines. On the one hand, extraction clearly separate the two tasks On the other hand, it induces 6 more ...
4
votes
1answer
55 views

Allocating a contiguous block of memory for an array

I try to work with a contiguous block of memory, to create an array (2D) whose SIZE is not known at compile time (before c99) so no variable-length arrays are involved here. I came up with the ...
0
votes
2answers
41 views

Two variants of a db_create_ressources(…) function

After reading noobs, I'm interested in possible way to improve readability of the following short snippet. a struct pictdb_file is a small file system containing ...
7
votes
4answers
355 views

Custom user input function

The program consists of 3 files: demo.c, mylib.c and mylib.h. The code is heavily commented. ...
0
votes
0answers
22 views

Recursive spinlock for C using ASM

My history of C/ASM locks here in codereview: Simple spinlock for C using ASM Simple spinlock for C using ASM, revision #1 (basis for this approach. If this one fails, then so will the one below.) ...
3
votes
0answers
40 views

Time Limit Exceeded with shortest path algorithm

The problem: SHPATH You are given a list of cities. Each direct connection between two cities has its transportation cost (an integer bigger than 0). The goal is to find the paths of ...
2
votes
1answer
30 views

Simple pool of threads which calculate the sum of a given number from the main process

I have to make a program which creates a number of threads that are waiting at the beginning, then the main process creates a doubly linked list where random numbers are put and then a signal tells ...
3
votes
1answer
50 views

Testing different implementations of malloc()

Can you help me verify my test result? I'm testing different malloc() implementations with a small program that allocates gigabytes many times: ...
3
votes
3answers
89 views

Counting the number of primes in C and C++11

I found this old piece of code that I wrote while I was learning C a while back: ...
2
votes
0answers
36 views

Simple spinlock for C using ASM, revision #1

Revision #1 for Simple spinlock for C using ASM The code: ...
4
votes
1answer
56 views

Simple spinlock for C using ASM

This is my second attempt to make simple lock using extended assembly. See http://stackoverflow.com/questions/37241553/locks-around-memory-manipulation-via-inline-assembly/37246263 The code: ...
1
vote
1answer
56 views

Structured, No Heap FizzBuzz

Here was my first, simple C fizzbuzz: ...
1
vote
0answers
28 views

Convert tri-gram of type wchar_t to an integer type

I am trying to convert a tri-gram containing 3 characters of type wchar_t to an integer type (an uint64_t at the present time). ...
1
vote
1answer
83 views

Reading from text files in C/C++ [closed]

I'm writing a program that has to check which are the two largest three digit numbers that are missing from a text file. I'm writing this in C++ and I'm trying to solve the mystery in a ...
3
votes
3answers
34 views

Array-based queue implementation using C

I wrote this header for generic use of a queue. The one thing I'm wondering is if I understood the usage of void*. I hope that if somebody teach me some conventions ...
3
votes
2answers
50 views

C - Improving (really) big number addition

I was lucky enough to stumble into this task during a job interview. I was gently guided to use string reversals and a few other things to speed up my process. I kept thinking that I wouldn't have ...
3
votes
1answer
61 views

Running shell commands in a pipeline

I'm writing a shell in C for Linux and BSD. My code was unreadable before but I did a rewrite and now it is much more readable. The purpose of the code is to create a command pipeline and execute it. ...
4
votes
1answer
41 views

Secure file system utility functions

For Khronos, I've had to develop these utility functions to help me deal with storing the .wav files. However, they could also be used in a variety of ...
4
votes
2answers
73 views

Recreating strstr in C

I'm trying to recreate strstr in c, my code works but I think it is too long, and it needs some improvement. ...
15
votes
2answers
350 views

The birth of my intelligent assistant: Khronos

I've done a lot of reworking to this main file recently, in regards to using a new speech recognition engine and integrating the last reviews suggestions. My question before is going to be phrased ...
2
votes
1answer
41 views

Median of 3 Quicksort in C

I'm trying to re-implement the C stdlib function qsort using a median of 3 quicksort. ...
5
votes
3answers
102 views

Simple file renamer in C

It's been some time since I wrote something in C. I am looking for some advices related to my code in terms of coding style, bad/wrong logic, optimization (performance) and good practices. The code ...
2
votes
1answer
51 views

Optimizations for bubble sort

The code performs bubble sort on the basis if any swaps has been performed in the iteration. I made it sort of independent of number of iterations as in any conventional bubble sorting code. I went ...
3
votes
1answer
26 views

AES Wrap function

This code is supposed to implement RFC 3394 which also described in this PDF at page 11. Are there any weak places or formatting issues in attached source? Or maybe some places are not explicit ...
4
votes
1answer
66 views

Small Poker program in C

I made a small Poker program with C but I believe I could've written it better. Full source on bitbucket.org ...
4
votes
1answer
41 views

Automake for an S/KEY implementation

I've been tasked with giving a legacy codebase some love. The actual code is written in C, but is not very relevant aside from the #includes each file makes. No, ...
-5
votes
2answers
48 views

Rewrite 12 consecutive ints based on bizarre logic

Despite looking terribly ugly, it is pretty interesting due to some specific connections to cellular automata theory. I'm looking for ways of simplifying it further. This program takes 2.7 seconds to ...