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
33 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
61 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
184 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 ...
-2
votes
0answers
18 views

Cannot figure out issue [on hold]

New to coding here. Really new (About a week) So in C, i am writing down this program - ...
-1
votes
1answer
15 views

Clearing Input stream (stdin) in C [on hold]

The following code is used to clean the input buffer while accepting successive user inputs. ...
5
votes
2answers
66 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. ...
-2
votes
0answers
14 views

C-Programming: Number Guessing Game [closed]

so I'm working on a number guessing game. I have most of the components down, but I still have a few issues. I don't know how to give the user the remaining number of tries they have (They are ...
7
votes
2answers
52 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
108 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
140 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
28 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
28 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 ...
-2
votes
0answers
9 views

Do I need to use the 'add' function in mips to store into a variable or can I store into a variable with load word? [closed]

The following problem deals with translating from C to MIPS. Assume that the variables f,g,h,i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address ...
3
votes
1answer
45 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
votes
0answers
20 views

Read data for a specific line in .txt file [closed]

The following code is supposed to read data from row 2 (i=2), but it always read data from row 3, (i=2+1) Can anyone explain why? Thanks. ...
1
vote
1answer
47 views
3
votes
3answers
52 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
19 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
82 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
39 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
28 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
132 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
72 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
56 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
60 views

Simple linked list program in C

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

MPI search the same set

I wrote a program that compares two sets of one main and checks that the set contains the same elements. I used MPI. I wanted to ask you about whether my program is correctly written. And if I could ...
4
votes
2answers
79 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
56 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 ...
9
votes
3answers
75 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
889 views

`atof` implementation

I have implemented the atof function. Here is my implementation ...
-3
votes
2answers
31 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
28 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
343 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
134 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
63 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
89 views

Natural merge sort in C

I have this C implementation of the natural merge sort: ...
8
votes
2answers
67 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
38 views

BMP writer in C

I recently wrote a BMP writer in C: bmpWriter.h ...
4
votes
1answer
39 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 ...
3
votes
0answers
43 views

Safe, fully standards-following integer abs in C

Here's a bit tricky one, because AFAIK there is no existing platform, where conditionally compiled part of the code would actually get included by compiler, so it is entirely up to the human review to ...
3
votes
2answers
251 views

C getline() implementation

I'm practicing my C coding and I wanted to implement my own version of the getline function in C for learning purposes. I'd like a review on coding style, ...