Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c]

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.

2
votes
2answers
40 views

Permutation of words in a sentence

There is a problem which discusses in how many ways can the words in a sentence be permuted . I wrote a code as follows which works for the sentences (I think so) . It would be helpful if anyone can ...
5
votes
4answers
16k views

Multithreaded Client/ Server communication

This is my first network programming codes writing for a client who has the following requirement: My Server has to run 24*7*365 for multiple clients at the same time (concurrency). Their Client (...
10
votes
3answers
2k views

Heavily limited premature compiler translates text into excecutable python code

My goal is to write a smaller compiler-like program, which allows me to draw geometric shapes into a 3D Diagram. There is no need for turing-completeness and the program should only be viewed as an ...
8
votes
1answer
112 views

Lazy, Functional Parser Combinators

Parser Combinators are the amazingly elegant way to write parsers that has evolved over on the functional programming side of the world, but have been less available or accessible for imperative ...
4
votes
1answer
62 views

Beginner Console Conway's Game of Life in C

For an Information System Security course I've applied to, I need to learn C and decided to start learning it yesterday. Conway's Game of Life has historically been a good project to start with, so I ...
4
votes
1answer
52 views

Iterable hashtable implementation in C

I'm just finished my version of iterable hashtable. I want to review code in general (code style, data structures, remarks about the algorithms) and I have some questions: I don't know how to ...
4
votes
1answer
49 views

Suspend and resume a thread using signals

The other day I ran into this question on stackoverflow. Just for curiosity I wanted to implement suspending and resuming the thread, so I used signals and used ...
10
votes
1answer
292 views

Credit card validation in C

I am relatively new to C programming and I am currently working through the CS50 EDX course. The problem I have solved below is for week 1 (credit). Any suggestions on how to improve this code to ...
2
votes
1answer
80 views

First attempt at making linkedlist in c

I started learning c and wanted to challenge myself by making a linked list. I am stil new to the concept of pointers and pointers to pointers, so there might be something in my code that I could have ...
11
votes
2answers
1k views

Implementation of the Jacobi Symbol in C

I am new to C programming and wrote the following algorithm for the calculation of the Jacobi Symbol. Though there are some faster versions of this algorithm available I am only looking for some ...
7
votes
1answer
36 views

Custom malloc implementation

I have a malloc() implementation that relies purely on mmap. I'm fairly sure that it doesn't overwrite any of the internal ...
-3
votes
0answers
30 views
6
votes
0answers
43 views

Console arkanoid in C

On an Internet forum a person came with their homework, to write Arkanoid in a console - it seemed they wanted someone to do their homework for them so I did not respond. However, I found the task ...
3
votes
1answer
45 views

Filling A Linked List With Data From File And Handling User Status Messages

I have completed an university assignment on C. While the code is fully functional based on the specifications of the exercise, I like high-quality code and would like to ask for opinions on how can ...
6
votes
3answers
3k views

Replacing each string of one or more blanks by a single blank

K&R 1.9 exercise: Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank. Is this correct and proper code? Could I have put ...
7
votes
1answer
64 views

Parse a WAV file and export PCM data

I'm a newbie and I wrote code that gets a WAV file and exports a RAW (only PCM data) to *.raw file. But I am confused about the structure. The code is written as one procedure (LISP style) and there ...
4
votes
1answer
75 views

Hashtable implementation in C for generic values

I am trying to implement a hashtable that supports character keys and can return any type of value contained in a struct as long as it contains as long as it contains ...
9
votes
2answers
846 views

The veiled guise of binary and string

Challenge Conceal a binary code within a word. Specifications The first argument is a path to a file. The file contains multiple lines. Each line is a test case represented by a space separated ...
5
votes
1answer
81 views

TicTacToe classic in C

I'm learning myself C and to make sure that I learn to code C in a proper way I created tic tac toe and want to hear your opinion on what I should do and what I shouldn't do. One thing is sure is to ...
-3
votes
1answer
72 views

Binary Search in C - Pointers and Memory [closed]

I got a warning when I am returning "list" in the function createList "Address of stack memory associated with local variable 'list' returned" I am confused about pointers and memory allocation and ...
2
votes
1answer
100 views

Simple program to hide messages in files (steganography)

That is a simple program to hide text messages in text files. I'd like to hear any advices to improve my code and style. Some notes: There is no error handling to simplify the program. It is not a «...
2
votes
0answers
23 views

Blocking serial port C library

I am planning to write a reasonably feature rich serial library but wanted to cut my teeth on something fairly basic. This serial library is fairly simple. It is a thin wrapper on the UNIX open, ...
3
votes
1answer
50 views

Verbose Brainfuck Interpreter in C

I decided to try and write a Brainfuck interpreter in C as an exercise. This could have been written in one file, but I decided to split it up into a State "class" and an some interpreter methods. An ...
3
votes
0answers
53 views

Striping a matrix concentrically, anticlockwise

Given a matrix you shall stripe the matrix, such that every number that has equal distance to the matrix border will be filled into an array. For examples see code comments. ...
6
votes
5answers
906 views

Convert UTF8 string to UTF32 string in C

I'm doing some recreational programming in C (after spending some time in C++, but professionally using only PHP/JavaScript). I wrote a UTF8 to UTF32 converter and just wanted to know if I made some ...
6
votes
3answers
180 views

Print strings in order with dynamic arrays

I accomplished the following task to practice allocating on the heap. reading words from stdin sorting them in lexicographical order printing the sorted words to stdout To accomplish this is ...
4
votes
2answers
158 views

Writing computer generated music to a wav.file in C - follow-up 2

See the previous iteration. What's new: endianness is now handled more gracefully (only one endianness check, and convertion if need be) and music is more funky. ...
5
votes
0answers
67 views

Finding duplicates in an array using C [closed]

I came across a problem on LeetCode. There is an input array of integers. I need to find out if there any repeating integers, then return true else false. So, I tried using a hashtable library ...
5
votes
1answer
38 views

Multiplying a Matrix with its Transpose

Currently, I am in the process of optimizing a MIPS assembly program that takes a n x n matrix and multiplies it with its transpose. I am trying to optimize my matrix calculation algorithm so that it ...
3
votes
1answer
41 views

Stern's diatomic series fusc: replacing #define functions with two return values

I have a function to review which implements Stern's diatomic series fusc for a single word (ulong = unsigned long) in place, as ...
17
votes
7answers
5k views

Tic-Tac-Toe for the terminal

I recently started learning C, and this is my first fairly large (to me) program. It's a basic Tic Tac Toe game for the console. There's no AI, it's just a 2-player game. Is there anything I can ...
-2
votes
1answer
41 views

Compute the results of a race against Achilles [closed]

I was given the task to write a code that takes inputs from the user that include the following: length of a certain race the speed of Achilles (the main participant) the number of participants ...
2
votes
0answers
31 views

Simple Socket Server in C for Windows

I have taken the code from a tutorial of Microsoft webpage. Of course, the example is for illustration only but I wanted to organize it and make it clear in order to understand it a little more. Here ...
7
votes
0answers
58 views

ASCII Mandelbrot Set “image” producer

As an exercise, I decided to try implementing a Mandelbrot Set viewer that produces ASCII images. Small Example: ...
4
votes
1answer
55 views

Preperiodic, periodic or aperiodic binary string

This is extension of the rep-string task from Rosette code. I do not only want to check if the input string is the shortest periodic string (rep-string) or not, but also check if it is preperiodic. ...
135
votes
17answers
16k views

Disproving Euler proposition by brute force in C

I wrote a little bit of code to brute force disprove the Euler proposition that states: $$a^4 + b^4 + c^4 = d^4$$ has no solution when \$a\$, \$b\$, \$c\$, \$d\$ are positive integers. I'm no ...
-2
votes
1answer
53 views

Optimizing a method that generates more than 1000 objects of the same type

This simple piece of software is generating a vehicle object by using the get_vehicle() function, Whenever i need to generate a specific vehicle I pass in the vehicle ID to this method and it ...
11
votes
3answers
2k views

Calculate min, max, mean and median out of array

Another C exercise: Write a function that takes an array of 'ints' as its input and finds the smallest and largest elements. It should also compute the median and mean. Use a ...
7
votes
2answers
122 views

Register “%b” conversion specifier

I'm writing a library to register the b, B conversion specifiers and make them work the closest possible to ...
1
vote
0answers
46 views

Linked list delete a node with a particular value [closed]

I am trying to search a single linked list with a particular value and delete it. Only the first occurrence of the value. ...
28
votes
4answers
4k views

FIFO data structure in pure C

I programmed a generic queue in pure C and I'd love to receive some feedback from other programmers. You may use the following questions to guide your review. Is the API well thought and idiomatic? ...
3
votes
1answer
61 views

Sums of columns and diagonals of a matrix

I made a simple matrix program that prints some data..I want to know how to reduce amount of lines with some functions or whatever, because there is so much if-s,and for loops. Tried to make ...
4
votes
4answers
2k views

Primitive console string calculator in C

Recenlty I have finished this primitive console string calculator in C. I need your balanced criticism, I'd like to know what I have to correct, remake and learn. Permitted operations: ...
2
votes
1answer
46 views

Computing the cost for creating a perfect square (with N = 3)

You are given a square matrix \$A \in \mathbb{ N}^{n,n}\$, this number contains integers from \$1\$ to \$n^2\$. The task is to compute the minimal cost, to change this square into a perfect square. A ...
2
votes
1answer
56 views

Computing the difference of the cross-totals of the diagonals of a matrix

I have solved a seemingly easy problem: Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix is shown below: $$\begin{bmatrix}...
1
vote
2answers
175 views

Multi-Threaded Cellular Automata Lab

I am trying to improve the performance of my cellular automata lab. I have two arrays of Doubles representing the current values and the next values. If I run the ...
2
votes
2answers
65 views

Split calculation string into parts

Our professor has given us the following task (its part of a bigger document full of tasks): Write a function in C that handles strings like "233+343" and parse them into the variables "iNum1", "cOp" ...
5
votes
2answers
130 views

First C program: records keyboard/mouse and simulates the recording afterwards

This is my first program ever made in C. Before that I programmed just a little bit in C++ (didn't touch OOP so I did only structural programming). This is my second "project" ever made, the first "...
19
votes
2answers
1k views

Yet another shell in C

I wrote this shell in C about a semester ago for a university assignment on operating systems. Even though I got a score of 10/10 in this assignment, I doubt it deserved it - The pipeline ...
1
vote
1answer
38 views

INI File configuration handler

I am currently working on a game, and I get the configuration in an .ini file, and I get information with this library https://github.com/benhoyt/inih I would like to improve the readability / ...