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
17 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
34 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 ...
6
votes
4answers
341 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
18 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
32 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
25 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
38 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
0answers
22 views

Pointer Manipulation C [closed]

I am getting a pointer in a function of type BYTE * where BYTE is nothing but typedef unsigned char BYTE; Now, if i am converting the BYTE * pointer to int * ...
3
votes
3answers
82 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
33 views

Simple spinlock for C using ASM, revision #1

Revision #1 for Simple spinlock for C using ASM The code: ...
4
votes
1answer
53 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: ...
2
votes
0answers
36 views

Grammar for loops and equality

I used lemon parser to write rules for while and == . The == rule looks like: ...
1
vote
1answer
54 views

Structured, No Heap FizzBuzz

Here was my first, simple C fizzbuzz: ...
1
vote
0answers
26 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). ...
2
votes
0answers
25 views

String manipulation for shell project

I'm writing a shell, have refactored my code from my previous question (especially the function that the answer was about) and would like a new review. The purpose of this functions is to split and ...
1
vote
1answer
74 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
32 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
49 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
50 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
35 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
69 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. ...
13
votes
2answers
336 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
99 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 ...
3
votes
1answer
62 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, ...
-4
votes
0answers
33 views

Printing numbers to a given number n and calculating the sum and count as well [closed]

This prints numbers to a given number n and calculating the sum and count as well, but my program is giving "time limit exceeded." Please suggest ways to reduce the complexity. ...
-5
votes
2answers
47 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 ...
-3
votes
1answer
41 views

Creating a struct

Mat told me to create a struct create a struct for the individual commands and arguments. It should have something like the "executable" name, number of args and arg list. Create a few ...
1
vote
1answer
48 views

Makefile and translating it to Cmake

My makefile looks like this and I translated it to cmake. ...
0
votes
0answers
23 views

Prefetch in ARMv7

I have to implement Khatri Rao product between 2 matrices in C. Mathematically this is a column major access of data and I can not change that. But if I use preload ( PLD instruction in ARMv7 ) to ...
-3
votes
1answer
52 views

Printing a prime normalized sequence

The program below generates a prime normalised sequence. So, what happens is this: It asks you to provide a number within a range. Program then calculates a factor which is inverse of product of all ...
1
vote
3answers
42 views

C single-linked list with remove

Can you please point out any problems with this C forward list with remove node functionality? I believe this can be way simpler ( removeNode function ) but I ...
0
votes
1answer
24 views

C function for copying array into matrix

I want a matrix that can grow dynamically and build up a structure in RAM as input arrives from standard input och terminal (shell). First I tried with a matrix like ...
3
votes
2answers
312 views

C dynamic array implementation using preprocessor

I have implemented a generic dynamic array implementation using defines. As I am new to C, I am not sure whether the code has any flaws. The code is as follows, ...
4
votes
1answer
50 views

Program to convert binary to hex

I wrote this program to convert binary to hex, it ignores other characters between the binary digits. I would like to receive any recommendations on how to improve it. ...
2
votes
3answers
53 views

Parabola calculations - follow-up

Previous question After applying the suggestions, I wanted to revise the question with the new code because I don't think this is good enough. ...
2
votes
1answer
73 views

Testing a shell command interpretor

I've written tests that use Bash for testing a custom shell. I think the tests work but I'm sure you know better because this is my first test I write this way. ...
2
votes
1answer
45 views

Find the contiguous subarray within an array (containing at least one number) which has the largest sum

Interview Q: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example: Given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray ...
0
votes
1answer
59 views

Shell command line program

I have refactored a for loop into a function. I'm still a beginner at using C utility functions such as strtok, ...
4
votes
1answer
57 views

Bubble Sort in C

I am trying to learn C coming from Python. Below is an implementation of bubble sort, slightly optimized. Any advice on best practices, readability, use of macros, and edge cases would be greatly ...
6
votes
2answers
204 views

Parabola calculations

I'm trying to make a small parabola calculator just for fun. Is this code good? ...
7
votes
1answer
53 views

Social network graph of characters in a novel

I wrote a C program that builds a social network graph of characters in a novel. The program takes two text files as input: a list of the names of the characters in the novel, and the file of the ...
2
votes
2answers
48 views

Shell command-line interpreter with pipeline parsing

Like many others I've been writing a shell command-line interpreter that can do a pretty decent pipeline parsing, first it splits the command at pipeline char (|), then it splits the substring at ...
0
votes
0answers
14 views

Reservoir sampling implementation in C

The distribution of unique values in input and output seems to be quite different in the following code, (h1), (h2); does the implementation have any obvious error ? ...
1
vote
1answer
34 views

Makefile and main header file for a shell

My main.c includes this header file. Please let me know how I can improve it. I did my best but I don't know much about code conventions in C (I come from Java and ...
2
votes
2answers
35 views

Print how many times a sequence of characters appears in a string

Given a string, count how many times a sequence of characters (in this code, the sequence is "ei") appears until the user types '#', then print the amount. I would like to know how to improve the ...
2
votes
2answers
66 views

Calculating the sum of the digits in 2^1000

I have a program which calculates the sum of the digits in the number 21000. The program is not beautiful and I was hoping for some advice on how to improve it. The idea I have used is to create an ...