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
2answers
73 views

Reading file into structure

At the time I'm trying to read a quite big file into a C program for later user. The file size is in the range of 800 megabytes containing around 20 million lines of data of the following format: ...
6
votes
1answer
39 views

CS50 pset-1 itsa Mario - make a half-pyramid using parameters from user input

I'm taking Harvard's introduction to computer science (CS50) course online, and I've written a program that satisfies a coding challenge but I don't understand what I did or how I can improve it. I'm ...
8
votes
1answer
346 views

ToyVM - a small and simple virtual machine in C - follow-up

(See the previous and initial iteration) Now I have refactored the code in order to conform to the suggestions made in the answers to the first iteration. I have this: toyvm.h: ...
0
votes
1answer
29 views

Loading message with Pthreads

I want to print a nice loading message with these three fading dots, while the main thread does some heavy IO stuff. This is why I implemented this: ...
3
votes
1answer
27 views

itoa with “method of complements” for negative numbers in ANSI C

I have enhanced my itoa implementation, taking the advise from my previous simple itoa implementation in addition to handling multiple radixes and negative numbers other then just base 10. Looking for ...
7
votes
2answers
86 views

ToyVM - a small and simple virtual machine in C + FizzBuzz demonstration

(See also the next iteration.) I have this small virtual machine. What is there: Stack and, thus, recursion. Conditional and unconditional jumps and, thus, choice and iteration. What is not ...
6
votes
2answers
622 views

Simple customer program in C (using binary files)

I have just finished a simple C program which is basicaly composed of 3 functions: accadd(void){} which adds some customer details to a binary file ...
-2
votes
0answers
23 views

How to change coding style when there're lots of condition? [closed]

For example, I have 2 variables and my code needs to select call which function according to these 2 variables' values. ...
0
votes
0answers
42 views

Red-black tree rotation

I am unfamiliar C coding styles and I had an idea to use a function pointer for this given piece of code. Typically, would it be aligned with current C coding style to use function pointers here or ...
1
vote
1answer
77 views

NDArrays in C: slicing/transposing/polynomials

This is the primary module for my APL interpreter. The general idea is motivated by my two Stack Overflow questions, but the details I fear are easy to get wrong and I suspect there are a few corners ...
4
votes
4answers
190 views

Validating a tab-delimited string

This code checks if string has correct format for passing to struct. Correct format needs to be [123456789'\t'First Name'\t'Last Name'\t'City]. I didn't know how to ...
5
votes
2answers
70 views

Electrocardiography simulator

I am tring to learn coding in clear way. I developed easy application to simulate EKG. I would like to ask some experts, if the code is clean and if they have any suggestion, what could I improve. ...
7
votes
2answers
57 views

Portable byte order conversion

I'm trying to improve the portability of a file format converter, specifically to POSIX platforms other than Linux. I'd appreciate a review of the following functions used for converting between ...
2
votes
3answers
112 views

Reverse digits and add until a palindrome appears

The following code is a C solution to the following problem UVA 10018. The Problem The "reverse and add" method is simple: choose a number, reverse its digits and add it to the original. If ...
6
votes
2answers
142 views

Student sorting based on criteria

This code takes id, name and marks of 3 subjects for 5 students from user base, calculates the total of 3 subjects per student, and then takes a criteria level with which to sort; level 1 sorting does ...
1
vote
1answer
30 views

Finding a delimiting character in a text file

I am writing a program that is capable of reading a matrix supplied from a text file. One intended feature of this program is that it should be capable of detecting various delimiters in the text ...
3
votes
2answers
29 views

K&R C Exercise 1-14: Histogram of the frequency of types of characters

This is for K&R C Exercise 1-14: basically asking to create a program that prints a histogram of the frequency of types of characters. This is done with very basic C functions/knowledge as covered ...
3
votes
1answer
47 views

Multiplying square matrix with C pthreads (POSIX threads)

I'm a student, and I'm trying to make the product of two square matrix with some threads in the soup. I've already worked on some fast single-threaded product (with some cache-friendly tricks), and ...
1
vote
1answer
49 views
3
votes
3answers
54 views

Simple string repeater program

I'm new to C, want to know if I'm doing this right. ...
1
vote
1answer
18 views

Binary Search Tree insert while keeping track of parent for node to be added - iteration 2

Follow up question to Binary Search Tree insert while keeping track of parent for node to be added I am implementing a red black tree for fun and am wondering how I should modify my basic BST ...
0
votes
1answer
20 views

Binary Search Tree insert while keeping track of parent for node to be added

This question has a follow up question: Binary Search Tree insert while keeping track of parent for node to be added - iteration 2 I am implementing a red black tree for fun and am wondering ...
3
votes
2answers
83 views

Quicksort for a pseudosite

I have a pseudosite, where I actually post small functions, so that I can re-use them*, but some posts have visitors. The top is Quicksort (C++). I feel that beginners visit it, so I do not care in ...
0
votes
0answers
41 views

Comparing two integers without logical, relational or bitwise operators - followup

Requirement: Compare the input numbers (granted to be non-negative) without logical, relational or bitwise operators and no if/else statement or ...
3
votes
0answers
31 views

Reusing curl easy handles in C

In a C project I want to reuse curl easy handles. The flow of program is like: Client --> C Application --> Call URL1, do something, Call URL2, do something, Call URL3... In short, for each client ...
6
votes
4answers
238 views

Numeric integrity check

I'm a beginning C programmer. I need a function that will take a string and determine if it's a number. The data is coming from files created by different people and the number formats WILL vary. So ...
4
votes
1answer
139 views

Lightweight logging library in C

I want to get some practice in writing C libraries and so started with something I can use straight away, a logging library. It is very basic and only has two levels: log everything and log only ...
4
votes
1answer
74 views

Comparing two integers without logical, relational or bitwise operators

I answered a question on SO today, however it did't receive any up-votes, so I want to know what's wrong with my code. The requirement is to compare the input numbers(granted to be positive) without ...
3
votes
1answer
50 views

Timestamp function with millisecond precision

I want to be able to print timestamps with milliseconds precision and time_t doesn't provide this. I also want the code to be portable, so operating specific ...
8
votes
1answer
60 views

Custom memory caching allocator in C

Over the weekend I built a fairly simple allocator: ...
4
votes
2answers
54 views

`atof` revisited

In an answer to this question I mentioned best effort. Here I try to explain what I meant. Please keep in mind that the implementation is intentionally incomplete (missing features such as ...
1
vote
1answer
64 views

Simple linked list program in C

This is my simple linked list program in C. What is the best way to write this? ...
4
votes
2answers
80 views

Un*x terminal history wiper

Using various answers from Stack Overflow and Ask Ubuntu, I've hacked together this simple C program that wipes terminal history. It works but I'm relatively new to C so I'm not sure if everything is ...
4
votes
1answer
58 views

Efficient image padding in C

I am currently implementing pyramids in Lucas Kanade algorithm for optical flow. To be able to build pyramids, I need to pad the images (mirror edge matrix elements) for the required amount of ...
10
votes
3answers
84 views

C itoa implementation

As an exercise, I limited my self to the man pages. I didn't look for a previous existing implementation because I wanted to see how well I could do on my own. I also tried to handle as many cases as ...
5
votes
4answers
892 views

`atof` implementation

I have implemented the atof function. Here is my implementation ...
-3
votes
2answers
33 views

Display calendar using a loop

Desired output: Can I get an shorter version of this code? My instructor just wants me to figure it out my self. ...
1
vote
2answers
40 views

Function that assigns names to a struct using strtok

I worked around using strtok function so to assign first name and last name to a struct PERSONNE from a ...
7
votes
2answers
107 views

Base64 encoding implementation

I am learning C and decided to make an implementation of Base64 encoding according to the info Wikipedia provides about it. My main question is: should I declare the index_table array inside the ...
2
votes
1answer
29 views

Matching patterns of characters

I was wondering if there are any significant improvements that could be made in order to make the program more concise or efficient, particularly in the findmatch ...
4
votes
4answers
347 views

Expanding compressed string

I wrote this for a problem in one of the online contest at hackerearth. Problem statement is: Input: The first line contains the compressed string in form a2b4h5a2 Expanding it ...
3
votes
2answers
61 views

BMP file writer

In my current project I'm writing a C function to write a BMP-File. Internally, the function is split up into three parts: write header, write info header, write data. In some of these functions I do ...
4
votes
1answer
140 views

Generate String with Random Consonants and Vowels in C

Replace all c / C / v / V in stdin with lower case, upper case consonants / vowels respectively. All other input is passed through. Anything that can be improved? ...
4
votes
2answers
65 views

Generate all permutations in C

I have written code for generating all the permutations in C as explained here. How can the code be optimized? Are there any memory leaks? ...
6
votes
2answers
216 views

Automation of array allocation in C

I recently have been working on moving from projects written in Java and C++ to C and realized that the lack of std::vector in C makes it a bit more difficult to ...
3
votes
3answers
90 views

Natural merge sort in C

I have this C implementation of the natural merge sort: ...
8
votes
2answers
70 views

Compiler for a minimal LISP dialect to run on the Java Virtual Machine

As the title states, this is a compiler written in C with a ruby build script that translates a minimal LISP dialect and spits out an executable jar file. I designed this LISP dialect and named it ...
0
votes
2answers
39 views

BMP writer in C

I recently wrote a BMP writer in C: bmpWriter.h ...
4
votes
1answer
40 views

A Generic Approach To Doubly Linked Lists

I've written a small implementation for doubly linked lists. While actually intended to be only used by me in subsequent projects, I wrote it as generically as possible. Maybe this'll be advantageous. ...
2
votes
2answers
99 views

Removing comments from a C source file

I wrote this program to remove comments from a C source file, accepting a file name from the command prompt. Let me know if I missed anything or if there are any improvements that can be made in the ...