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

6
votes
3answers
53 views

Fastest way of removing a substring from a string

Taking a break from my C++ series, I recently reviewed the code in this question. I ended up writing my own separate derivation of the function so that I could remove all of the substrings from a ...
3
votes
1answer
38 views

Function for rendering custom fonts

I have a function that converts any normal true-type font to my own font file .bff That function works correct and am not going to post that function for that matter (the function is also only ...
6
votes
2answers
158 views

Trim a string to a given start and end

Are there any other more exotic ways ... or is this one just good? ...
3
votes
1answer
77 views

Example String Class in C

I wrote this small example piece of OOP being implemented in pure C. I wanted it to be reviewed for the following points: Portability Performance And especially Usability "How does it look" ...
2
votes
2answers
32 views

Merge all files in a directory with a specific extension

I come from Python, with a bit a FORTRAN and Matlab some years ago. I'm trying to learn C. My first attempt at a program is one to merge all the files in a directory with a specified extension ...
4
votes
2answers
39 views

Lopsided Trees and Recursion

The original problem is: Define the height of a binary tree to be the number of nodes in the longest path from the root to a leaf. The empty tree is considered to have height 0. A node is ...
8
votes
3answers
531 views

Randomized response generator for number-guessing game

I am currently learning C and playing around with the rand() and if/else statement. This ...
4
votes
1answer
45 views

Convert an `int` to a C string with size limitation

Creating a textual version of an int to save as a C string to a buffer that is all ready allocated and maximum allowable size is determined seems common. Thought ...
0
votes
0answers
51 views

Code optimization sugestions required [on hold]

I have following code snippet which i am thinking of optimization little more. Do you guys have any suggestions? There are 6-7 conditions of the same type, I have just written example for 3 ...
0
votes
0answers
26 views

repeating problem with Simon says game? [closed]

overview of the assignment: Simon says game of 4 level, random number 1-4 only;start with one digit then keep adding until hit the user input level. i have few problems, and i cant seem to find them. ...
-1
votes
0answers
21 views

Array implementation of Stack in C [closed]

The code is http://ideone.com/Ha70ph I've tried to create an implementation of Stack using arrays. I am having some problem in the loop. The program runs, it asks for the choice and from switch case ...
2
votes
1answer
46 views

RFC PS Rasterizer Library API

We've got the basic functionality of using my postscript interpreter, xpost, as a library. I'd like to solicit some feedback from the community on the API setup. ...
1
vote
1answer
80 views

Performance critical optimization routine with many arguments

A possibly similar question has been closed, but I'll give it a try anyway. A performance critical part of MATLAB code, a trajectory optimizer, has been moved to C (subroutine ...
8
votes
1answer
168 views

Logical shift with signed numbers

I am going through the Coursera course The Hardware/Software Interface and because it has already ended, I would not be able to get any feedback on the code. The assignment is: LogicalShift: ...
5
votes
2answers
71 views

Example of a Multithreaded C program

In answering password cracker in c with multithreading, I ended up writing a sample in C, which is not my forte. Is there anything that I missed which should have been included in a responsible ...
3
votes
2answers
97 views

Writing strings to a file

This opens a file and writes 5120 times a string to it, and if the file doesn't exist it creates a new file. The name of the file and the string are chosen randomly. I would like to know if there is a ...
6
votes
3answers
131 views

Byte swapping functions

I recently programmed some byte swapping functions. As a special I did a function which can convert an entire int array. I please you to look at the following aspects: portability performance ...
3
votes
1answer
50 views

Implementing a linked list

I am studying data structures at the moment, so I want to see if there is anything wrong with my implementation of linked lists in C, after I checked Implementing an ArrayList. Header ...
4
votes
3answers
121 views

Implementing an ArrayList

I implemented ArrayList functionality in C as follows: ...
6
votes
1answer
67 views

MicroC task switching

My background for this review is a university course in embedded systems using MicroC and this question. Now my program appears to run ok, but I'd like to know what you think can be improved or if the ...
-1
votes
1answer
46 views

ArrayList implementation in C [closed]

Although I know I can use calloc then realloc to make a dynamic array in C, and that I also need a variable to keep track of the ...
7
votes
3answers
162 views

Validating lines in a file using certain specifications

I have written a program which basically reads a file named "data.txt" line-by-line. As a line is read, it validates the line with a certain specification. If the specification is met, it will ...
3
votes
0answers
40 views

Parallel accumulated sum in OpenCL

This is my first relevant code in OpenCL. Please, let me know if I'm doing something wrong in a logical level (i.e., I guess it can crash in situations?) or accounting for performance (bottlenecks, ...
0
votes
0answers
9 views

Matrix Game SPOJ [migrated]

I solved this problem on spoj: Two players A and B play the following game. First, a matrix M of size N*M is chosen, and filled with non-zero numbers. Player A starts the game and ...
8
votes
2answers
586 views

Simple calculator

I created my first program in C: a simple calculator. I want to know if it is possible to make this code more effective. Is it, for example, possible to change the calculator function so that I don't ...
15
votes
2answers
168 views

Interprocess Communication in a Farmer-Worker setup

The following code is my first C program I have made for an university assignment about Interprocess Communication. This involved creating a parent process, the farmer, and then creating a certain ...
5
votes
4answers
169 views

C library that converts integers to string and vice-versa

I've created this little library to help ease myself (and for others, hopefully) with the pain of having to convert integers to string and vice-versa. It's written in C, and for maximum portability I ...
10
votes
2answers
251 views

Simple key-value store in C, take 2

Followup to Simple key-value store in C. Response to previous reviews You may want to hide the KVSstore structure Done. Add a comparison function pointer to KVSstore. If this pointer is ...
5
votes
2answers
77 views

Simple key-value store in C

I needed a simple key-value store. Here's what I came up with. Usage Use kvs_create and kvs_destroy to create stores and clean ...
7
votes
2answers
86 views

OpenGL text rendering library for Lua built on freetype-gl

FTGL wasn't making me happy, so I decided to try something else. This isn't completely finished; I plan to work more on layouts and alignment, and add a few other things. It should be far enough along ...
5
votes
4answers
108 views

Dynamically-sized stack - follow-up 3

Follow up of - Dynamically-sized stack - follow-up 2 I've took the tips given to me, and what I did now is: Use same case type for type stack and it's functions Returning 1 if push failed due to an ...
8
votes
1answer
41 views

Lua bindings for FTGL (FreeType font rendering in OpenGL)

I wrote some Lua bindings for FTGL's C API. This works well enough, but I ended up with lots of macros, one for each Lua function signature. For example, LUD_NUMBER_NUMBER_TO_NUMBER creates a Lua ...
5
votes
4answers
208 views

Creating nodes for linked list in a while loop in C

I am trying to create nodes for a linked list in a while loop. The code works, but it is not very pretty. How would I get the same results the proper way? ...
6
votes
1answer
59 views

Dynamically-sized stack - follow-up 2

Follow up of - Dynamically-sized stack - follow up I've took the tips given to me, and what I did now is: changing the function names to have a prefix making the ...
4
votes
2answers
92 views

Translating warning codes as messages to be printed

I am writing an X application with Xlib in C, and this code is for error handling and error printing. How to make it simpler and clearer without using a large amount of ...
4
votes
2answers
126 views

Dynamically-sized stack - follow up

Follow up of - Which is a better implementation of a stack data structure (based on an array)? Please review my stack implementation from before. I've made it dynamically sized if needed and made a ...
2
votes
1answer
59 views
8
votes
4answers
505 views

Three functions for computing simple arithmetic

Here is my code where I have 3 functions that do simple arithmetic: ...
2
votes
1answer
44 views

Sorting an int[] array using insertion sort algorithm - follow-up

Previous questions: Is my implementation of insertion sort is correct? Sorting an int[] array with an Insertion Sort I'm currently learning about different sorting algorithms and after reading on ...
5
votes
1answer
52 views

Sorting an int[] array with an Insertion Sort

I'm currently learning about different sorting algorithms and after reading on the concept of the insertion sort of how it's done I've tried to implement it by myself before seeing how it was ...
2
votes
1answer
47 views

Is my implementation of insertion sort is correct? [closed]

I'm currently learning about different sorting algorithms and after reading on the concept of the insertion sort of how it's done I've tried to implement it by myself before seeing how it was ...
3
votes
2answers
85 views

Merge sorting linked lists

This works as expected and I want to get this code reviewed so that I can improve my coding ability. I am concerned about readability and the quality of the code ...
2
votes
2answers
59 views

Comparing two bubble sort algorithms

I'm learning C and I've got to a point learning about different sorting algorithms. Before seeing how it was done, I wanted to try doing it myself based on what I read on how it's working. ...
12
votes
0answers
75 views

Tiny Lua library to get char pointer from string

Background I'm using Lua with luaglut to do some OpenGL stuff. The luaglut API is almost identical to the gl/glut C APIs. Sometimes, gl functions want a pointer to some data, for example: ...
10
votes
4answers
483 views

Prime Factorization

I'm doing an Objective-C project and I need to do some prime factorization and so I came up with the following algorithm which is 99% C, except for the array part which was easiest to implement in ...
7
votes
4answers
127 views

Simple compression algorithm

An implementation of a simple compression algorithm that's featured in a programming practice book. My goals: Robust: All error conditions must be handled properly. The specification indicated in ...
5
votes
3answers
186 views

Bubble sorting in C

I've been into algorithms lately, so I wanted to apply a simple algorithm using a language of my choice, which was C in this case. I've implemented the bubblesort algorithm (for strings) in a simple ...
2
votes
0answers
25 views

POSIX: Synchronous event library

I have implemented a small library that handles synchronous events with POSIX compliant threads. I oriented me on the already existing POSIX thread API. Here are the files I created: ...
0
votes
1answer
45 views

Possible memory issue in linked list program [closed]

I am trying to write a program which will count the occurrence of words in a paragraph. The logic I am following : I am using a linked list for the purpose. And I am searching sequentially - if new ...
9
votes
3answers
477 views

Checking for palindromes using dynamic memory allocation

This is a homework assignment, but it's already done and it's not for a grade; it's meant as a refresher for the rest of the course. I've never done anything with dynamic memory allocation in C ...