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
3 views

Suggestions for storing and comparison of strings in better way

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 'c' to 'd'. ...
7
votes
3answers
78 views

Simple shell in C [on hold]

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 ...
2
votes
1answer
32 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 ...
2
votes
2answers
117 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
29 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
33 views

Trajectory optimizations

Here's a function doing some trajectory optimization in the following manner: ...
6
votes
3answers
59 views

Singly Linked List Implementation in C

I'm preparing for an interview soon, and I've written the following linked list implementation from scratch. This is all self-taught, and I'm still working on my C. I feel that the implementation is ...
4
votes
3answers
90 views

String case reverse function in C

This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Besides documentation, in particular, any thoughts on the type ...
3
votes
3answers
29 views

Trimming fgets(): strlen() or strtok()

After a successful fgets(buffer, ...), it is often desirable to trim potential End-of-Line \n. Of the following 2 methods, any ...
0
votes
0answers
22 views

The Monty Hall Problem (with functions) [on hold]

I have been asked to make a Monty Hall style program where there are 3 doors, one that has a prize behind it and the user has to guess which one. After he guesses, one door will be revealed and he ...
-2
votes
0answers
15 views
0
votes
0answers
21 views

Recursive BubbleSort Not Working [on hold]

For some reason my recursive bubblesort function won't work anymore. This was a homework assignment that I had worked when the homework was due, but now I'm getting what looks like a memory error. ...
-4
votes
0answers
34 views

For loop index post-increment vs pre-increment [on hold]

I've always written for loops with the index variable being post-incremented, but recently I've come across a lot of code with the variable being pre-incremented. ...
5
votes
4answers
209 views

Character permutations - Revisited

Several hours ago I posted this question about Generating character permutations in Python. User rolfl said that my main problem was not using the right tool for the job, as Python is interpreted it ...
7
votes
3answers
507 views

Concatenate two strings

I am learning C and wrote a function to concatenate two strings in C. Please let help me improve it. ...
5
votes
1answer
37 views

Converting decimal integers to a string representation in an arbitrary base between 2 and 26

This code takes an integer and returns a string representing the value in a different base. The value for the base can range between 2 and 26. I have had someone already look over this code and they ...
4
votes
2answers
86 views

Minimum Spanning Tree using Prim's algorithm

I have implemented a Minimum Spanning Tree using Prim's Algorithm. Could someone give some about some improvements for code structure, conventions, performance, etc? ...
4
votes
4answers
831 views

*Code for fake UI

While I was coding it, I got a better idea, but I continued because I can not compare both of those ideas, because they are different. The idea of that function is to make your fake ui-building ...
3
votes
1answer
62 views

Applying scalar multiplication to matrix

This is one of my first programs in C. Please review and help me improve it. I create a matrix and apply scalar multiplication on it. Then I print the result. ...
-5
votes
1answer
47 views

Count percentage of audio samples exceeding a threshold

I have this practice question that I have an answer to: In this stage of the project, you will identify any "danger" spots, in which the SPL is greater than or equal to 80 dB (the value above ...
11
votes
4answers
162 views
+50

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
45 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
179 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
88 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
35 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
44 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
548 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
48 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 ...
-1
votes
0answers
56 views

Code optimization sugestions required [closed]

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 ...
2
votes
1answer
47 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
84 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
169 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
73 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
132 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
51 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
124 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
48 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
163 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
42 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
591 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
169 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
170 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
259 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
79 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
92 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
109 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 ...
9
votes
1answer
44 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 ...