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

1
vote
2answers
36 views

Primitive console string calculator on C

Recenlty I have finished that, in fact, described in the title of this topic. I need your balanced criticism, I'd like to know what I have to correct, remake and learn additional. Waiting for your ...
1
vote
1answer
72 views

HPC kernel for DGEMM: compiler v.s. assembly

This is a correct version, for computing a small matrix multiplication: C += A * B, where C is ...
1
vote
0answers
16 views

Color String Macros and ports of useful PHP string functions

Here is a code file (I use it as a stand alone header file to be included in my projects) that contains macros to generate ANSI encoded strings that when printed are colorized. Also, the module ...
2
votes
1answer
39 views

Peterson's Algorithm (Mutual Exclusion)

A simple algorithm that can be run by two processes to ensure mutual exclusion for one resource.Shared variables are created and initialized before either process starts. The shared variables flag[0] ...
0
votes
0answers
16 views

Error implementing a linked list array in C [on hold]

Hy to everyone. For a couple of hours now, I've tried to implement an array of linked lists. I would like to implement K-Way-Sort in C, but it seems I can't figure out why I don't make a proper memory ...
-7
votes
0answers
30 views

test.exe has stopped working when trying to get a simple temparature converter to work [on hold]

I'm a novice and started learning C just a few days ago. So far I've learned if and else statements and how they work. So I wanted to make a program that will convert celcius to fareheight and vice ...
0
votes
0answers
11 views

AVX2 method to average 4x4 block of UINT16s

Consider the code snippet: ...
-2
votes
0answers
30 views

RSA Algorithm for C [closed]

I have implemented a easy RSA for C. I don't know why it can't be decrypted when I change 'p' and 'q' values. But, It is working with fixed values p=7, q=17 ...
-1
votes
0answers
13 views

How can I replace scanf for %s and change the input and output behavior? [closed]

This is my parentheses balanced program. I didn't attach stack.c and stack.h. I already checked this program to my TA and I got a comment like this. Your stack is supposed to grow and shrink ...
3
votes
1answer
47 views

Common client server implementation

I have created a common C file for a basic client server. It works fine on my Linux setup. Please provide your comments/suggestions on how the code can be optimized/enhanced. After compiling we need ...
0
votes
0answers
15 views

Common Server Client Code [closed]

I have created a common c file for a basic client server. It works fine on my linux setup. Please provide your comments/suggestions on how the code can be optimized/enhanced. After compiling we need ...
2
votes
2answers
67 views

Intentional performance degradation through cache and branch-prediction misses

I am experimenting with performance evaluation. From the hardware architecture point of view, two main factors are cache misses and incorrect prediction of conditional branches which can degrade the ...
3
votes
1answer
69 views

My C code for Fibonacci Sequence

I've been learning more programming in the past few years (C, Java, Arduino) for my hobbies. I read the "C for Dummies" book and found that it was good, but did not cover much - especially pointers... ...
2
votes
2answers
56 views

Implementation of exp function in C using Taylor Series expansion

I am trying to write code to calcultate ex using: $$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots $$ This is the code I have, which works ...
2
votes
2answers
111 views

Python style with-statement in C

I thought about using a macro to auto close FILE pointers at the end of a block. My solution so far is: ...
3
votes
2answers
131 views

Validating e-mail address input in C

I have this little function to validate e-mail. It's a little piece of code to search major mistakes in e-mail input and it's part of a bigger program I have to complete as a school assignment. Is ...
5
votes
0answers
46 views

Simple OpenGL image viewer in C

I'm making an image viewer and before I continue development I want to make sure I haven't done anything bad. In particular, I was wondering if my error handling is sane. Most of the code is ...
3
votes
2answers
58 views

Blackjack game program

I'm learning C and decided to write my first major project in C. I was bored and wanted to play blackjack so I decided to create my own game. My program starts the user off with 500 credits and ...
3
votes
0answers
54 views

Graph Library in C

Could you guys please review the Graph Library I developed in C? It's also on GitHub ...
3
votes
0answers
27 views

Mounting a disk with the DiskArbitration framework

I have the following code that makes use of the DiskArbitration framework to mount a disk to its default location: ...
1
vote
1answer
26 views

Using semaphore in C

This is my first time using semaphores and I was wondering if I implemented them to the best of their abilities in my code.... ...
25
votes
5answers
2k views

Event scheduler in C

One of my university assignments asked us to create a program using struct in order to create a simple event scheduler. This program is for a single day only, not ...
3
votes
1answer
39 views

Reading arbitrarily long lines from a file that is redirected as input

So I have a file with a list of dates that are to be redirected as input to stdin and what the program does is it searches for valid dates, appends them to the output file and then appends all the ...
9
votes
2answers
287 views

Circular Buffer in C - Follow Up

This is a follow up to this post I uploaded a few days back on my alternative account about a circular buffer in C. I'm confident that I fixed most of the warnings and even added an iterator. ...
3
votes
2answers
42 views

Generic Vector Implementation

I'm in the process of writing a Generic Container Library in C called CGCL (https://github.com/ta5578/C-Generic-Container-Library). One of the generic containers I'm implementing is the vector ...
2
votes
1answer
52 views

Counting the number of increasing sub-sequences

The problem is to find the number of increasing sub-sequence of a string with only digit characters. Answer may be very large, so output it modulo 10^9+7. I have been able to get a O(n) solution ...
7
votes
3answers
93 views

Circular Buffer

For my current project I need a circular buffer, which is able to do the following things: Push something to it (to the head). Pop something from it (from the tail). I don't need the popped data. ...
7
votes
4answers
180 views

Find the dominator in an array of integers

A zero-indexed array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elements of A. For example, consider array A such that ...
1
vote
2answers
181 views

Print every character in a line if it's greater than 80 characters

How can I improve this program? ...
8
votes
5answers
379 views

Adding two numbers, each digit as a single element of array

After failing to answer an interview question, I went back home and coded the answer for my own improvement. The questions was: Given two arrays containing a number, but with each element of the ...
3
votes
3answers
99 views

An assignment algorithm in C

As a post processing step of a similarity matrix computation that leads to the non-negative matrix mt4_ in gpu, I am performing an assignment step to determine ...
0
votes
0answers
15 views

Writing simple base code for a program that keeps track of my work hours and pay in C [migrated]

When I compile my code it says that everything checks out but when I run it nothing happens. The program just runs until I kill the terminal. ...
3
votes
4answers
84 views

Dynamic array of integers: another attempt

This is follow up to this one. In the previous some minor errors slipped, so I couldn't update the code. Also took some advice. So final version is below. header: ...
1
vote
2answers
46 views

Dynamic array of integers

I implemented a vector class in C for integers. Any feedback welcome. header: ...
4
votes
2answers
87 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: ...
7
votes
1answer
55 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 ...
9
votes
1answer
411 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
34 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
36 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
95 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
630 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 ...
0
votes
0answers
43 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
87 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
194 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
71 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
58 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
120 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
143 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
2answers
32 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
33 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 ...