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

tab completion for custom shell

The purpose of the code is to enable tab completion for a custom shell I'm writing. The target os are Linux and OpenBSD. I had to make a conditional include that I hope is correct: ...
9
votes
6answers
711 views

Given three numbers, find the second greatest of them

I've just coded this for my country's programming Olympiad. I want to know if this method is a good approach in terms of readability and performance. I would also like to know how to improve it. Note:...
3
votes
1answer
19 views

Simple program to insert values in a linked list

I tried to write a simple program using linked list where I just insert the value stored in every node and then through a function print the values. This is the code: ...
2
votes
1answer
29 views

Segment tree challenge

Here is my implementation of a segment tree with a sample driver file (I didn't make an update function because I didn't need it for what I was doing). I'm a huge fan of geeksforgeeks, but I do not ...
-2
votes
0answers
20 views

Parsing through a tangled linked list [on hold]

The struct function is: ...
4
votes
1answer
56 views

Max difference between two array elements

Can I get feedback on below code? Problem statement is Maximum difference between two elements such that larger element appears after the smaller number Would this solution be still considered O(n) ...
8
votes
2answers
29 views

My own snprintf implementation in C

I decided to make my own version of snprintf in C. I intentionally changed some things though. My version guarantees the buffer printed to will be null-terminated, ...
5
votes
1answer
84 views

Checking that a password contains a '$', a digit, and an uppercase letter

I have this code, which reads in a string password from the user and checks if it has a dollar sign $, a number, and an upper case letter. If it has all three, it ...
0
votes
2answers
55 views

Fizzbuzz in C for console

I imagine I get a minuscule performance improvement by doing the %3 as a branch off the %5 rather than the other way round or as an if '%15'. Am I correct about that? (I know there is no practical ...
5
votes
3answers
490 views

Snake game in C for Linux console

Please help me improve this code. Move snake using : a w s d. (My compiler doesn't support initialization of index variables inside loops, so please ignore this part) ...
5
votes
2answers
307 views

itoa base function in C

This is a function that converts an integer value to a null-terminated string using the specified base and stores the result in a char array that I must allocate (...
4
votes
2answers
87 views
-1
votes
0answers
17 views

CS50 pset1 - hacker1 [closed]

I'm beginning my journey into computer science and I've started with the CS50 course. The first problem set requires you to check if a number might be a valid credit card number by using Luhn’s ...
5
votes
3answers
108 views

Pausing a loop with a Raspberry Pi 3

I am trying to perform a loop and then stop the loop when the last line of code in the if statement is printed to screen saving on CPU cycles. I want to start a <...
2
votes
1answer
41 views

Recursive spinlock for C using ASM, revision #1

Precursor for this revision here in code-review: Recursive spinlock for C using ASM Improvements have been made thanks to forsvarir. Now I am trying to optimize this lock so it becomes more ...
0
votes
0answers
20 views

Reduce encoded length of UTF-8 encoded Ruby string in C extension

I'm writing a Ruby extension in C. It's a string processing module working on UTF-8 encoded strings only. One method, full_width_to_ascii!, converts full width ...
4
votes
2answers
62 views

Processing trip route table in C

In fact, this is a group assignment for our C programming lesson, but seeking help from others is not considered cheating. The goal of the following code is to: Sort the data in ...
-4
votes
0answers
23 views

How do i fix the getnameinfo and library (Linux C)? [closed]

Hi everyone who is reading this, i need a huge help on this code it needs to fixed on two things: 1-the library is not worling well for a code that i added (it is located between bars like "//////////...
2
votes
2answers
29 views

Small Poker program rewrite

I had already put up code for review a small poker program but I have rewrote it utilizing a more appropriate data structure. How would I compare Poker hands accordingly? Full source repo ...
1
vote
2answers
25 views

Sorting structures lexicographically

I am swapping structure lexicographically by name. Is there any way to improve the code when the structure entries are heavy. Here is the code ...
-1
votes
0answers
16 views

Making my own Vigenère cipher in C [closed]

I'm new to stack exchange so if there's any way to make my post more clear let me know. I might miss providing some general information that's usually including in a veteran's stack exchange post, but ...
4
votes
1answer
106 views

Printing fizzy lines

Challenge Given a test case print out a FizzBuzz Series. Specifications The first argument is a path to a file. Each line includes a test case. Each test case is comprised of three spaced ...
1
vote
3answers
82 views

Recursive function that reverse the words in a string

I have been working on a problem that asks me to a write recursive function that can reverse the words in a string. For example if the string is "cat is running", then the result should be "running is ...
3
votes
1answer
102 views

Finding the prime factors of a positive number

I have an assignment to write on the standard output the prime factors of a positive number displayed in ascending order and separated by '*'. My code works, but I need help reviewing it before I ...
7
votes
1answer
57 views

Longest lines using priority queue

Inspired by a comment on this question, I thought I'd exercise my C skills by implementing something like it using a priority queue. The idea is to be able to invoke the program like this: ./...
6
votes
2answers
762 views

C the large print

This is the Longest lines challenge from CodeEval: Challenge Write a program which reads a file and outputs a specified number of lines, sorted on length in descending order. ...
4
votes
1answer
43 views

Bottom up (iterative) mergesort in C

I have this C implementation of the bottom-up (iterative) mergesort: mergesort.h: ...
1
vote
1answer
36 views

Parsing and executing a simple shell script

I'm writing a simple shell and want to parse and execute a simple shell script. ...
7
votes
3answers
2k views

Implementing atoi() in C

I was given a school assignment to implement atoi(). Please review my code. ...
7
votes
4answers
900 views

No more filthy words

Challenge Given a list of words mixed with extra symbols. Write a program that will clean up the words from extra numbers and symbols. Specifications The first argument is a path to a file. ...
4
votes
5answers
124 views

Test four int of commonality in the lower four bits

The four parameters a, b, c and d can be ...
10
votes
2answers
1k views

Tic Tac Toe vs PC

Please help me reduce its complexity and maybe optimize it a little bit more. ...
3
votes
0answers
69 views

CUDA program that emulates a kind of cellular automata slower on the GPU than on the CPU

I'm a very new to CUDA, so I'm still trying to understand how to make the best use of the GPU. I've ported a C algorithm to it. This algorithm works by loading the memory with an initial input, then ...
8
votes
2answers
76 views

Thread to send heartbeat UDP packets

This C code will run on an embedded machine with a Linux OS. It should create data packets (ASCII) to repeatedly be sent to a UDP server. Just to give an overview about what functions should do: <...
1
vote
1answer
53 views

Mergesort algorithm in C

I have this mergesort implementation that has exactly the same API as qsort: mergesort.h: ...
3
votes
3answers
99 views

Helper utilities for easier benchmarking in C

I have this tiny library for measuring the execution time in milliseconds and returning the duration plus the result: execres.h ...
16
votes
1answer
192 views

Get Minimum of four and maximum up to a limit

Sita shortlists 4 gifts priced at r1, r2, r3 and r4 respectively. She wants to buy 3 of these gifts such that it doesn't exceed her budget of x. Input and Output Format: Input consists ...
4
votes
4answers
616 views

C Socket Part-1

In my ongoing attempts to become a better blog writer I have some written some more code that needs reviewing. Full Source: https://github.com/Loki-Astari/Examples/tree/master/Version1 First Article: ...
6
votes
2answers
114 views

Longest palindrome in an array

I am new to programming, and think this code could be improved upon. Any suggestions? ...
-1
votes
1answer
35 views

More error-checking

The purpose of this code is to check for errors in my code for a custom shell. In a previous answer, they say that my code didn't have error-checking. You need to check the result of every ...
8
votes
2answers
73 views

Hash table OOP implementation in C

To brush up my C I decided to do some OOP programming in C. I have never tested this before, but I was curious to try it since seeing an example of it a while ago. I decided to implement a simple hash ...
1
vote
1answer
38 views

Unit test with check testing framework

I have some code where the purpose is the decide if a char is between quotes in an expression. For example, awk '{print $1}' has a ...
15
votes
1answer
103 views

Arduino Snakes and Ladders

Here is a snakes and ladders game I made using an Arduino using a serial terminal, a set of addressable LED's to create a physical game board, a 7 segment display, and a piezoelectric to create sound. ...
2
votes
0answers
37 views

MPI BMP image comparison

I made a simple program in which I compare two images pixel by pixel and determine if the pictures are the same. I'm trying to adapt it to MPI, but I'm afraid that the communications are taking too ...
1
vote
0answers
85 views

Unwrapping multiple inner loops in CUDA for 4D nonlocal filter

I'm working on some sort of non-local means filtering in 4D space (x,y,z + time). The idea is to pass to GPU a chunk of large 4D array in order to process it and return a filtered 3D slice (then ...
3
votes
2answers
52 views

Extracting the longest line from standard input

I'm reading the K&R book and I'm interested in a program which finds the longest line on the input. I've written the same code as in the book, but I wanted to do it myself. I tried to write my own ...
12
votes
1answer
75 views

Platformer in C

GitHub repo. main.c ...