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

Number of interesting numbers between two given numbers

Please have a look into this problem: Little Dipu is a small kid and like all the other kids, he likes to play, but he plays with numbers (he is extraordinary you know). Nowadays Dipu has some ...
0
votes
0answers
12 views

fix ms compiler c code to compile in gcc [on hold]

Hello, I have some very basic understanding of c/c++ language after reading one c and one c++ book to about a half each for over 15 years ago. Around that time also, in 1998-9ish, I've bought a book ...
5
votes
2answers
226 views

Keeping integer addition within bounds

I have to read a int8_t from a buffer, read a uint8_t from the camera's current settings, add them together, keep new value ...
0
votes
1answer
17 views

Copy memory blocks of different sizes

Is there a better way than this to copy the values from source to destination when the blocks of memory you want to copy to and from are different sizes? Also considering you have no control over ...
0
votes
0answers
44 views

Removing an internal node from a complete Binary Tree [on hold]

Problem Statement : Create and maintain a Complete Binary Tree in C. Include the following operations. Insert a given key and perform inorder Replace ALL occurrences of the given key with the then ...
-1
votes
0answers
9 views

A code to evaluate what date it will be after n days [on hold]

I've been trying to implement a program that, given a date \$a\$ and a integer \$n\$, returns the date \$b\$ which is \$n\$ days after \$a\$. For example, if \$a\$ 3/4/2015 and \$n=2\$, we should get ...
1
vote
3answers
83 views

C-string appender for buffers and strings

Is this C appender safe, and reasonably optimal? ...
3
votes
2answers
32 views

Program to evaluate powers of complex numbers

I'm trying to develop a simple program to evaluate integral powers of a complex number \$z\$ , that is, \$z^n\$, where \$z\$ is in the algebrical form \$a+i b\$ and \$n \in \mathbb{Z} ^{*} _{+}\$. ...
5
votes
1answer
62 views

“Laser treatment” SPOJ challenge

I am trying to solve this problem on SPOJ Brazil. I'm trying to approach the problem with a series of logical conditions and my code looks like this and it works perfectly. ...
2
votes
1answer
45 views

Readers-Writers problem in C

I would love some suggestions on this code of mine, pointers on overall design, code quality, optimization in terms of memory and speed. ...
3
votes
2answers
36 views

Converting from base-10 to word

The following code is used to convert a base-10 number to a base-N number, where N is a length of a given alphabet that contains characters of which a base-N number ...
1
vote
0answers
13 views

Entering base characters one-by-one for a List [closed]

This function should prompt the user to enter bases characters (a, g, c and t) one-by-one and then insert them in the List. ...
0
votes
0answers
10 views

The following code should Blink an LED as a function of an input frequency [closed]

I wrote a code to blink an LED using PIC 16F17889. It compiles using MPLAB X but nothing happens on my board. I set the frequency to some value to test it but the LED doesn't blink at all. I dont know ...
5
votes
2answers
142 views

Edge cases for simulated malloc function

I'm trying to simulate the malloc function in C by using mmap and having 2 linked lists to act as memory blocks. The program ...
2
votes
1answer
39 views

Array-based FIFO queue in C

I have this "generic" implementation of an array-based FIFO-queue. As I have written very little code in C, I don't have an idea what to ask, so feel free to tell anything that comes to mind. ...
8
votes
0answers
55 views

HTML/XHTML/XML tokenization

I want to write a library to parse any valid or invalid HTML-like things. First of all, I am trying to build a lexer. Here is what I did; ...
1
vote
1answer
43 views

Minimum sum of numbers

The code reads an input with numbers and find the sum with the minimum difference of the first two big numbers. The sums are three. Is there is any way to make the code cleaner? (Note that I don't ...
5
votes
4answers
477 views

C Doubly Linked List

It works, but it seems a bit long winded. I'd like some critiquing. ...
2
votes
1answer
26 views

Printing simple histogram horizontally

I am new to programming and want to know if this is really bad code. I know my variable names may seem arbitrary but I spent some time trying to get them right. I am struggling on that. Would you do ...
2
votes
1answer
36 views

Byte-to-binary conversion function

My implementation of a binary-to-bits converting function: ...
2
votes
1answer
23 views

Can I be checking that buttons are pushed in a better way?

I made a panel of buttons which run commands when pushed. In order to not have the command run on every loop if the button is held down, I am comparing the button to a previous state and only run if ...
3
votes
1answer
35 views

Reading a file into memory

Can you review below code for performance and stability considerations? It is supposed to take a filename or NULL. If it is a filename, read given file into memory. ...
3
votes
1answer
32 views

Blinking LED code at a particular frequency [closed]

I wrote a function for interacting with my PIC16F1788. The code sends pulses out the RC4 port at a specific frequency, to make ...
0
votes
1answer
46 views

Optimizing Diwali Lights problem in C

I was trying to solve the Diwali Lights challenge on HackerRank. Problem Statement On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set ...
1
vote
2answers
43 views

Optimizing the runtime of the bisection method

For those who aren't familiar with the bisection method for finding the root of a function (i.e. finding where \$f(x) = 0\$) the basic idea is: take a function \$f(x)\$ and an interval \$[a,b]\$ if ...
0
votes
1answer
20 views

Moving between two angles in a set amount of time [closed]

I need to slowly change from one angle to another angle over a certain amount of time, using the shortest path between them. I have a function that accepts four parameters — the start and end angles ...
3
votes
1answer
37 views

Dynamic array implementation

I would like to use code below for general purpose dynamic array implementation in my future code. How does it look? array.h: ...
2
votes
1answer
36 views

Implementing dirpath(3p) and fdirpath(3p) functions

I'm implementing a dirpath and fdirpath functions, which allow to retrieve path from the directory handle (or its descriptor). ...
1
vote
1answer
47 views

Data structure for inserting and replacing data in list

I have a list of key value pairs, that is used as an intermediate store for building URL parameters or JSON data. Currently this is done with a linked list: ...
1
vote
1answer
50 views

ROT13 algorithm in C

I am trying to learn C and I came across the ROT13 scrambling system used to store some passwords. Assuming the user types everything in correctly (uses 1 argument, uses a string not an int, etc.) ...
2
votes
2answers
60 views

Prime factors of a number in C

The following is code on "prime factors of a number". Any suggestions to optimize the code? It runs for a pretty long time for inputs like 35068499. I also want the code to take 10 digit numbers as ...
7
votes
1answer
44 views

Restrictive stupid shell

I'm attempting to create a replacement shell for /bin/bash, that only permits commands defined by a read only config file. These commands will be run by absolute paths, and take no arguments. I'm not ...
2
votes
1answer
45 views

HackerEarth Crazy kangaroo challenge

I want to find the lowest hop count from source to destination. The challenge, in summary: The first line contains the number of test cases T, 1 ≤ T ≤ 100000. The next T lines each contains ...
3
votes
1answer
38 views

Network byte order to host byte order

While doing a little project involving sniffing packets, I found myself programming a cross platform network to host byte order and host to network byte order, this is my first time developing a ...
4
votes
1answer
27 views

K&R Exercise 1-20: tabs to spaces

I'm learning C with K&R 2nd Ed. I've just completed the exercise 1-20 and I would know if my code is correct (i.e. answering the question) and if my style is not too bad. Or just some feebacks to ...
3
votes
2answers
46 views

Rapid color replacement for in-memory BMP

A function that relatively quick replaces one color with another, in a memory-buffered BMP. I am trying to improve the performance as much as it is possible. The previous implementation of this ...
3
votes
2answers
50 views

Functional-style linked list written in C

For my Operating Systems class, I needed a linked list data structure and didn't have one already written. During the course of thinking about how to implement a linked list again (it had been a ...
4
votes
1answer
24 views

Simple file locking wrapper command in C

A simple command that wraps another command, locking a file first. It is similar to flock, just simpler. ...
3
votes
2answers
54 views

Small library for logging to MySQL

I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. This library is going to be used from all of my other programs ...
4
votes
0answers
93 views

malloc(), free(), realloc() using brk() and sbrk()

I recoded malloc() by using brk() and sbrk(). I just want some "reviews" to see if it is ...
3
votes
1answer
33 views

Variable to byte decaying function

A function that prints out the values of each of the bytes of a variable, which value is given from stdin. Consists of size detector and a loop. ...
7
votes
3answers
450 views

RPN calculator in C

I had to write a RPN calculator in C as one of my homework problems, but if someone could critique my code and suggest any improvements, that would be fantastic! I haven't added any overflow errors or ...
6
votes
3answers
238 views

Reading, echoing, and returning integers in an array

I was wanting some clarification on my code, as I am new to pointers in C. I am trying to return an array from a simple function just so I can understand exactly what it is that I'm doing. Here is ...
9
votes
1answer
127 views

Reading, processing and counting an array setting limits

Last weekend my teacher asked me to create code to solve a problem: Giving a dynamic array, we want to pass the array elements from a file. The first number in the file N gives us the array ...
6
votes
2answers
84 views

Gauss elimination

The gauss function takes 3 parameters: a pointer to the matrix of coefficients the number of variables a pointer to matrix of solution ...
6
votes
3answers
381 views

Harvard CS50 Problem Set 1: greedy change-making algorithm

The goal of this code is to take dollar or cents input from the user and give out minimum number of coins needed to pay that between quarters, dimes, nickels and pennies. If this code can be ...
14
votes
1answer
90 views

Coroutines in C

Please have a look at this little coroutines library ccoro: http://sam.nipl.net/code/ccoro I'd appreciate a general code and style review, and your kind comments! ...
8
votes
2answers
78 views

FizzBuzz Challenge

This bit of code is a small game to see how long you play a game of FizzBuzz without messing up. Code: The top of the code: ...
2
votes
1answer
58 views

Hash table with double hashing

I writing a hash table with double hashing. This code works ONLY with ASCII text files and finding the number of occurrences of each word in input file! Please point out mistakes and shortcomings. ...