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

3
votes
1answer
38 views

Prints out to stdout all possible combination of printable ASCII 7-bit characters

This takes over 60 minutes to execute. The program is small in size, about 16kb. I am thinking that the repeated calls to printf slows it down significantly, rather ...
1
vote
2answers
29 views

Efficiency of sieve of Eratosthenes

Can I make this more efficient? ...
0
votes
0answers
25 views

Is using for loops the only method to perform matrix multiplication in C/C++? [on hold]

for (i = 1; i <= x; i++) for (j = 1; j <= z; j++) { c[i][j] = 0; for (k = 1; k <= y; k++) c[i][j] += a[i][k] * b[k][j]; } I ...
5
votes
1answer
79 views

toBase64 encoder

My code convert text to Base64. I used the algorithm without bit operations. What do you think about my code? ...
-1
votes
1answer
38 views
-1
votes
0answers
33 views

Base64 DECODER optimization

...
5
votes
1answer
60 views

Custom Memory Allocator in C

I made this because I need to make a program that creates and destroys huge trees in gigabytes for hours or time. The default malloc/free in MinGW/GCC is too slow. ...
0
votes
2answers
23 views

Determining coefficient in geometric progression

For an assignment at Uni we had to code a program that takes numbers as input and determines the coefficient if they form a geometric progression once you declare EOF (ctrl+z). If the user inputs a ...
1
vote
4answers
134 views

Reversing a string in place without using iteration in C

This is function for reversing a string in C using recursive calls: ...
4
votes
2answers
58 views

Translation of Number Systems

My code converts a number from one number system to another (from binary to 36 and back). Do you think my formatting is successful or not? ...
-1
votes
0answers
22 views

Are void functions faster than normal int functions in C? [closed]

I'm an amateur programmer in C and i'm wondering if or why running functions as void instead of int yields faster run time. For instance ...
1
vote
0answers
30 views

Treap with implicit keys

I implemented an implicit treap and tested it a little. It works fine but I'd like to know if there are ways to improve/simplify things and/or if some parts are incorrect. Later, I'll augment code to ...
-3
votes
0answers
11 views

Array Won't Print All of The Elements When Compiled [closed]

When I compile my program in Visual Studio 2012 it will print the first element to the screen, but then will wait for the user to press enter before printing the next element. I want the program to ...
0
votes
0answers
17 views

C programming - linked lists [closed]

When i run the following program, for some reason the code gives me a segmentation fault (core dumped). ...
9
votes
3answers
435 views

Implementation of an Stack without Linked Lists in C

I'm a beginning C programmer. As an exercise, I have attempted to implement a stack of strings in C. This is my first real exercise working with pointers. I looked at some other similar posts on here, ...
3
votes
3answers
51 views

Copy a directory from source to destination

I wrote a program that copies a directory from a source to a destination, similar to the cp utility. For this, I used the essential functions: ...
8
votes
4answers
727 views

Fruitmachine game

I'm quite happy with my code so far but I often make efficiency errors that I don't see when writing code. Have I missed anything? ...
5
votes
2answers
231 views

Reading, counting, and processing integers from a text file

The following code reads a .txt file that contain only numbers. Read the first one, create a dynamic array and put the other numbers on it, made some procedures and in the end write a file with the ...
4
votes
3answers
191 views

Splitting and printing comma-separated values

I stumbled upon a question on SO asking how to split a comma-separated string into individual values. Since it's been a while since I've had any good reason to write C I'd like to ask for some ...
0
votes
1answer
57 views

String search & replace in C

I created a function to do that, and I want to know if there is a problem I'm overlooking about it .. ...
0
votes
0answers
48 views

Freeing a binary tree data structure in C

I have this function that I hope to be a good alternative to the recursive (thus performance expensive) approach. ...
1
vote
0answers
14 views

Basic Unix shell that displays prompt and has two simple commands [closed]

I'm writing a really basic shell for Unix in C. It displays a prompt, [almond], and it has two commands: Set Prompt and exit. I'm reading user input and passing it to a char array, then parsing it ...
2
votes
0answers
83 views

Function to replace color in .bmp

I wrote a function to replace color in a bitmap image. For beginners in image processing, it could be exclusively useful, since they could use it to replace the entire gamma of a color or to replace a ...
3
votes
3answers
192 views

Reading and printing sudoku input

I have seen programs to solve sudoku puzzles but to be honest.. They were badly written. First of all, readability of the program itself was horrible and the code was really long and confusing. So I ...
2
votes
2answers
48 views

SPOJ problem: Life, the Universe, and Everything

Your program is to use the brute-force approach in order to find the answer to Life, the Universe, and Everything. More precisely, rewrite small numbers from input to output. Stop processing input ...
1
vote
1answer
42 views

Creating an insert at front function for a circular doubly linked list

I have only been working with C for a couple of months and I think I have a pretty good function to insert a node in the front of the circular doubly linked list. I have tested in adding several ...
-1
votes
2answers
71 views

Decomposing a number into primes

I have written the following code to decompose a number into primes. The problem is that it takes so much time and I have no idea why. ...
3
votes
1answer
61 views

Google CodeJam Round D APAC Test

Problem A: Vincenzo decides to make cube IV but only has the budget to make a square maze. Its a perfect maze, every room is in the form of a square and there are 4 doors (1 on each side of the ...
6
votes
2answers
151 views

Merge sort using sentinels

This is my implementation of recursive merge sort, using sentinels: ...
1
vote
2answers
36 views

Circuit-Swap mechanism on going (BMP->PPM)

Reffering other "Stack Exchange" Sources, I've been told that the only way of swapping BGR to RGB involves buffering. While this isn't true, I could just perofrm a quick C-SA algorithm on ...
3
votes
2answers
253 views

4x4 Sudoku solver performance

The code is for a 4x4 Sudoku solver. It works fine when there are a small number of unfilled spaces (0's) but when I give the whole matrix input as 0's or so the solver takes a very long time. I need ...
3
votes
4answers
179 views

Function to extract bytes as a decimal

You give this function a pointer and how many bytes you want to extract as a decimal and it returns it. ...
6
votes
3answers
71 views

Two implementations of file-reading

I work quite a lot with file reading and writing in C/Win32 and I started wondering if my code is completely ugly and how I can improve it. I wrote two simple examples of reading a file, and I wonder ...
8
votes
2answers
210 views

Implement a stack using a linked list

I am to implement a stack in C using a linked list. My code is below. My design: I use stack_ prefix to each function, and each function has a ...
6
votes
2answers
67 views

Structure and readability of basic calculator

I created this code to make a basic calculator after viewing a few examples. I added the function to continue the calculations myself. I am wondering if there is a way to make this more efficient as I ...
4
votes
2answers
117 views

Counting the longest increasing subsequence in an array of integers

This is my finished function to find the length of the longest consecutive subsequence of an input array of integers. It's for an assessment so things like the numerical method used and the format of ...
1
vote
2answers
50 views

Launching links to a chat room - Invitation Program

This is a program you can compile on Windows. The program is an invitation of a chat system for programmers. Once you press enter, you will open the link with your default Internet browser. You can ...
0
votes
0answers
13 views

Chess in C: Negamax implementation works but sometimes doesn't spot mates in 1 [migrated]

I implemented negamax with alpha beta pruning and quiscence search and it seems like it works... except for sometimes the computer lets me mate in 1, even though there were moves that it could've done ...
8
votes
3answers
274 views

Red Black Tree Implementation

I would like some feedback on my red black tree implementation. Anything is fine. I've debugged this and it seems to be working fine, however I may have missed something. Basically, this is a red ...
12
votes
1answer
197 views

Find binary sequences with low peak sidelobe level of autocorrelation function

I would like to find all binary sequences from the specified range, which has low peak sidelobe level of its autocorrelation function. Here is solution (this is simplified version of the real code) ...
4
votes
2answers
42 views

Chained hash table implementation

While reading a data structure book, I have implemented a chained hash table. I want to share the code with you and get your opinion about it. chained_hash_table.h ...
7
votes
3answers
185 views

Linked list C implementation

I'm reading a data structure and algorithm book in C. I have implemented a generic single linked list in the C programming language, and I want to know your opinion on my implementation: ...
-3
votes
1answer
62 views

Function to count unique colors in bmp [closed]

This function is supposed to work: ...
6
votes
2answers
110 views

Generating 'Decent' numbers

While solving a problem from HackerRank, though it's aneasy one, I wrote this big program. Not sure if recursion is applicable and hold good but to me it looked like it isn't. However when I run the ...
1
vote
2answers
73 views

“The Love Letter Mystery” - storing and comparison of strings

The problem goes like this. Change the strings provided by user to form palindromes. To do this, 2 rules are: (a) Reduce the value of a letter, e.g. Change 'd' to 'c', but cannot change ...
7
votes
3answers
168 views

Simple shell in C [closed]

I am just getting started with C and made this simple shell to test my understanding of some basic principles. The shell reads commands from standard input, forks itself and executes the command. How ...
4
votes
3answers
74 views

Finding strings inside of other strings in order in C

A question on Stack Overflow recently intrigued me to the point of me implementing the functionality in C. Can you critique this algorithm and tell me what is good and bad about it? This program will ...
3
votes
2answers
137 views

Function to get the most frequently appearing pixel

What i have so far is a nice and rapid algorithm for finding the pixel dominant from bmp image. I am not sure how to make it to work.. i though it works, but the program freezes. ...
2
votes
1answer
47 views

Binary Search in C

The standard C library function bsearch wasn't giving me correct results, apparently. So I decided to implement a binary searching function in place of it. It ...
1
vote
1answer
55 views

Trajectory optimizations

Here's a function doing some trajectory optimization in the following manner: ...