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.

Filter by
Sorted by
Tagged with
-3
votes
0answers
14 views

gcc compile time warning flags [closed]

I am using the following gcc warning flags when compiling a C program with gcc: -Wall -Werror -Wextra -Wundef -Wunreachable-code -Winit-self -Wparentheses -Wconversion -Wsign-conversion -Wsign-compare ...
1
vote
1answer
62 views

Can you criticise my Snake Game in C?

This is my first year at university, and I'm trying to learn everything about fundamentals. I've coded a snake game recently in C. This is a programming-challenge that I've given to myself to practice ...
4
votes
2answers
114 views

All In One Stock, Program for My business

I built my first program to solve an issue occurring at my self-owned business.. This program I made after learning a bit of C. It took about a month to make and what it performs is various functions ...
1
vote
3answers
52 views

c beginners calculator

I wrote this simple calculator and I want to know if there is any problems in it or if there is any way to enhance the code and make it simpler and easier and I also want to know if I'm starting to ...
-1
votes
1answer
35 views

Unexpected result when simply filling an array [closed]

So, I have been trying to understand this simple code and why it doesn't produce the expected result. Here is the code : ...
3
votes
2answers
108 views

A very basic Black Jack program, which just lets you play one round without any balance or betting

I just wanted to make a fun project for practise and as far as I know the program runs just fine without any flaws, but I would like to add an option to it, if a round ends to ask the user if he wants ...
3
votes
1answer
49 views

C Typed Vector that implements type-safety, encapsulation and lazy initialization

C Typed Vector I wasn't happy with the various dynamic array / vector implementations in C, so I made my own. In general, I'm not the biggest fan of C-preprocessor madness, but alas for this ...
4
votes
1answer
101 views

Binary Thread Scheduler

The term, I used, binary thread scheduler means a scheduler that orders the execution of two threads for two tasks that has a specific dependency. Rather than using some mathematical expressions to ...
0
votes
0answers
78 views

Binary Tree Level-Wise Creation and Traversal

I have used a queue, which has been implemented using a singly linked list, to facilitate the level-wise creation and traversal of the binary tree. ...
2
votes
2answers
80 views

C99 - An alphanumeric random char generator

I have built a very small program that is a command line utility for generating alphanumeric characters of a certain length (up to a max. length) called randchars. <...
1
vote
1answer
28 views

simple code that tries to establish tcp handshake. Creating tun device | what ever ip packets message comes try sending valid response.checksum&TCP

So I am getting packets from TUN interface and after that processing the packet, and then try to send correct TCP handshake response message. It does handle sequence and ack sequence handling but That ...
2
votes
1answer
61 views

Generating a random ipaddress in C

I was looking to receive some feedback on the function I wrote to generate a random ip address. The code is pretty messy and just wanted some feedback regarding optimizations, memory leaks and best ...
4
votes
2answers
59 views

Linked list implementation for a beginner in C

So I've decided to dabble a bit into C, and while it's trippy as heck I've finished an implementation of a linked list for practice. I've pretty sure there's some type of obscure bug or memory leak in ...
5
votes
4answers
489 views

Find the earliest date from a series of inputs

I need to find minimal date (year, month, day, hours, minutes, seconds). My code is working, but it looks terrible and it's very long. What can I do to avoid this ladder and make my code readable? (I ...
7
votes
2answers
89 views

Network utility tool

I wrote a little program in C based on some requirements: Ping every IP from a file and check the result Show, by network adapter, ONLY the IP, subnet, default gateway and DNS Check the speed between ...
3
votes
1answer
80 views

Simple stopwatch in C

A very simple stopwatch. Intended to be used for simple benchmarking when you want to do a task several times, but exclude some setup code from the benchmarking. Some things I have already considered: ...
1
vote
2answers
56 views

Dynamically allocating a 3D-array in c

I want to use dynamically allocated data, corresponding to a 3D array in a C program. After using the data, I would like to properly deallocate the data again. My approach is as follows: ...
3
votes
2answers
132 views

str_join() function, not present in standard C library

This function str_join() is an updated version of my earlier function strcat_new() [Found here: https://codereview.stackexchange.com/questions/270524/strcat-new-function-not-present-in-standard-c-...
2
votes
0answers
21 views

Task manager with dependencies (revisited)

This is a new version of the todo(1) utility I published some time ago. Now I use julian days rather than time_t to hold time; and the topological sorting is ...
1
vote
2answers
89 views

Find most occurring word in a sentence

Here is my C code for finding the most occurring word in a sentence: ...
2
votes
1answer
53 views

Parsing A Simple Matrix Definition In C

In one of my homework projects, I have to parse a matrix definition into a matrix data structure in C. The elements of the matrix will be given in a list of double. I need a simple tokenizer and ...
1
vote
1answer
43 views

Given an array of integers randomly selected from 7 to 13 (included), build a function that remove the primes in the array

I am trying to solve the following exercise: "Consider a function ​ removePrimes() be a C function that takes as input an array of integers, removes all numbers that are prime, and returns the ...
11
votes
3answers
2k views

strcat_new() function, not present in standard C library

strcat_new() function, not present in standard C library. Syntax: char *strcat_new(char *delim, long num_args, ...); The code is ...
11
votes
2answers
1k views

Multi-threaded web server serving HTML, images, etc

I have a web server that can send websites, images, mp3 and other things and I was wondering how I could improve the code and make the server more efficient. ...
2
votes
3answers
179 views

Simplified print and input macros in C

For a program I'm writing, it requires a lot of printing and receiving user input. I've found it cumbersome to keep specifying the type strings in printf, and ...
4
votes
3answers
329 views

Functions in C language that manipulate strings, not present in the standard C library

I have implemented few functions in C language that manipulate strings. These functions are not present in the standard C library. string_library.c ...
0
votes
1answer
54 views

Line-wise input, EOF handling, and behavioral differences between implementations of getchar

I've implemented a menu system where all input calls ultimately go through io_getline, a function which reads a line of input up to the max buffer size or newline (...
1
vote
1answer
54 views

Create a linked list from an array, and also free that list

I'm currently learning C/C++ and I saw this question on Reddit on how to create a linked from an array and decided that would make a good exercise for learning the absolute basics of C, so without ...
1
vote
1answer
88 views

Generic doubly linked list in C

I have implemented generic doubly linked list in C language in which you can store any data type you want. Just like in C++ and Java, where a list can store any data type, like - string, int, long, ...
3
votes
2answers
433 views

Simple string manipulation in C (for small microcontrollers)

Although I have long experience of other languages, I've not used C until playing around with microcontrollers using the Arduino IDE. I'm a bit uncomfortable with my use of pointers in conjunction ...
-1
votes
2answers
65 views

Caesar's cipher decoder works but Valgrind shows many errors [closed]

The program is a Caesar's cipher decoder. It compiles and works ok, but in Valgrind, I receive a lot of errors and I have no idea how to solve them. I have tried with --track-origins=yes, but I still ...
3
votes
1answer
86 views

Monte Carlo Simulation of 7 Card Stud Poker

I've completed this as part of an online programming course (in which code review is supposed to be done by fellow learners, but it's been a very long time and none of them have reviewed this), and ...
2
votes
3answers
115 views

Finds Keywords in Log Files

This is my first project in C and I wanted a more experienced person's insight on how I made the whole program. Just looking for feedback it works how I want it to. The Github is here. Thank you so ...
1
vote
2answers
73 views

Sorting numbers using Insertion method

In this program I've tried the insertion Sort method to execute ...
2
votes
0answers
45 views

Implement easy CLI options in C using a single-file header

I'm a computer science student, and in 2 of my courses this semester we are writing short C programs to demonstrate the things we are learning about. All of these programs require command-line flags &...
1
vote
2answers
49 views

Low level tcp socket

Since I am a Unix newbie, I wanted to know if the code reflects the "unix" style and if there is something to add for it to be robust. P. S. I hope I am not overusing ...
12
votes
5answers
4k views

My first C program: quadratic formula calculator code

Recently I've started to learn the C programming language. This is my first program which finds zero places of quadratic formulas. Doesn't parse, just gets the discriminants, counts delta and x1, x2. <...
3
votes
1answer
80 views

Implementation of a type-safe generic dynamic array in C

I'm new to C and was trying to write a generic dynamic array which is type safe. I'm not sure if I pulled it off in the best way possible though. dynarray.h: ...
3
votes
2answers
91 views

Branchless Fizbuzz in Posix C (no if-s, ternaries, switches or loops)

Yesterday when I was showering I was thinking of branchless programming and a thought occurred to me, whether it's possible to write a branchless solution of the Fizbuzz problem. The constraints I put ...
3
votes
2answers
55 views

User-friendly string struct and utility function - upated version

Updated previously posted string struct and utility functions Previous link: User-friendly string struct and utility functions What is updated ? typedef of sstring is a major update. previously, ...
3
votes
2answers
70 views

Stack API for generic values

I'm trying to create a stack library from scratch. It stores generic elements which are passed in void* pointers. This is the defined structure: ...
1
vote
2answers
50 views

Evaluate the roots of Bhaskara’s formula

I'm creating a program that finds the roots of Bhaskara’s formula and prints them. I'm looking for advice to improve my logic more and more. ...
2
votes
2answers
80 views

First C program - Tic Tac Toe 2

I have already posted this program and got some good recommendations on how it can be improved but I would like to further know what can be improved for example: Should dynamic memory allocation be ...
3
votes
3answers
42 views

Filter a list of integers to exact multiples of a given factor

There is a sequence of integer values, and a separate integer. I was required to write a method to get all numbers from the given number sequence which can be divided exactly by the given separate ...
5
votes
1answer
90 views

Open addressing linear probing hash map

Here is my wheel. strmap - C string hash map. Main goal - create usable and simple alternative to hcreate_r, ...
7
votes
2answers
1k views

Assign determisitic Orcish names for debugging

Orcish Large volumes of unlabelled data are hard to visualize when debugging; I find it difficult to keep track of the pointers in memory. I have used this code to assign Orcish names, (it's a name ...
13
votes
4answers
2k views

Vector Implementation in C

I made a somewhat simple vector implementation in C. Right now I only have around 5 features (making a vector, adding elements, removing elements, changing elements, deleting the vector). I'm proud of ...
2
votes
1answer
35 views

Total income program: budget and savings calculator

I started my cs50 course this week and I will be trying to make little projects alongside to reaffirm what I've learned thus far. Here I have made a very basic budget and savings calculator, I am ...
0
votes
2answers
112 views

First C program - Tic Tac Toe

Hi I am a beginner and l would love to hear your opinion on my first C project, how can it be improved in any way, for example dynamic memory allocation isn't used in the program because I didn't ...
6
votes
6answers
2k views

Left Shift/ Right Shift an array in C

I am trying to implement a Left shift/ Right Shift on arrays. I was able to accomplish this using double loops. Can the efficiency be improved? This is the working code for LeftShift/RightShift which ...

1
2 3 4 5
72