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
0
votes
0answers
14 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
36 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
36 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 ...
9
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 ...
-2
votes
0answers
32 views

C, atoi. Своя функция atoi на C [closed]

Please, tell me, why this code doesn't work without "-'0'" in this string:"result = 10* result + (str[i++] - '0');"? Объясните, пожалуйста, люди добрые, почему код не работает без &...
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
166 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
298 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
52 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
50 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
62 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
421 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
63 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
52 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
67 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
72 views

Sorting numbers using Insertion method

In this program I've tried the insertion Sort method to execute ...
2
votes
0answers
44 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
48 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
76 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
85 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
52 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
69 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
46 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
77 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
41 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
82 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
109 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 ...
4
votes
1answer
256 views

Implementing a pipe-like program without wait?

So I implemented a program that takes an input file, two command strings and an output file to mimick the behaviour of running : ...
2
votes
2answers
188 views

User-friendly string struct and utility functions

Created a new typedef and functions supporting it, making it user-friendly [specifically programmer-friendly]. What does the code do? It makes users [programmers] easy to deal with strings as most ...
1
vote
2answers
65 views

Simple server to host simple website page with css

I have created a simple server that host html that has css. Please make sure if ur testing then change the paths relative to ur system in listhell.c in respond_main(..) function. The html file has to ...
3
votes
2answers
257 views

Function to create single linked-list

Given the following data struct: typdef struct lista { int num1, num2; struct lista* sig; } nodoNum ; and a declared ...
2
votes
3answers
112 views

Convert string to integer and catch errors

I have attempted [and made one] function to convert string to integer and catch errors in pure c Working method The whole working method is present in code itself The header file The str2num.h here:- <...
6
votes
2answers
147 views

Console battleship game made in C

I started out to learn more about C to learn more about low level programming and hardware and I can improve. It generates a random number between 1 and 4 then stores it into two variables. It takes ...
5
votes
3answers
1k views

FizzBuzz, but with provided start and end of sequence, results stored in array, and a separate function to convert integers to strings

To learn C, I'm doing the traditional FizzBuzz challenge with extra restrictions: The start and end of sequence is provided by the user Instead of directly printing the results, the results must be ...
2
votes
3answers
67 views

Phrase to acronym in C from exercism.io

I am learning C and doing challenges like those found on exercism.io and the various data structure & algorithm sites. I have a sense that while this works and it makes sense to me that it can be ...
-1
votes
3answers
79 views

Populate a color table in XCB

This function has 16 repeated calls to the same function, passing in the same handles to each: ...
2
votes
2answers
30 views

Making a program that lists files in a directory and sorts the output using stat()

I wrote a program that uses stat() to find some details of all the files in a current directory. I then store all that information into a string using sprintf() and keep adding to the size to prevent ...
4
votes
3answers
119 views

Circle & Sphere Calculator

I've just wrote my first real C program. It calculates the dimensions of a circle or a sphere based on the user input. The program asks the user which dimension they are entering and then prints the ...
2
votes
2answers
81 views

use C to create uniq()

So my friend told me he just did 1 while and a bunch of if-else with only using 3 arrays to get the same output as mine code does. So I wonder if I just make this unnecessarily complicated. I have ...
5
votes
3answers
360 views

Software ECC embedded with a parallel NAND Flash interface

I'm developing an embedded solution (STM32L4R5 MCU - Cortex-M4F: 120 Mhz / 640 kb of ram) featuring a parallel NAND Flash (MICRON) interface and my platform lacks hardware ECC computation powerful ...
0
votes
2answers
147 views

Clock in C language

Ok, so here's the code: Please, comment if there are mistakes ...
1
vote
0answers
42 views

Counting Cram game positions in C

This code counts the number of possible positions in the game of Cram on a mxn board. EDIT 1: In the original question I mistakenly mentioned that this number is ...
1
vote
1answer
49 views

Server hosting single page site using TCP sockets in C

I have written a simple server to host my page and CSS (CSS file is 22KB). Using sockets and TCP. Can any one please review it and give feedback on how can I make my server reliable using TCP and ...
2
votes
1answer
85 views

Writing an x64 Code Emitter to eventually make a full fledged Assembler like NASM

As the title suggests, I'm writing an x64 Code Emitter. Right now I've only encoded 1 instruction (The add instruction). I want to know if this API can be improved at all. This is how you I use it. <...
7
votes
2answers
179 views

2D Maze Game with Monsters

Introduction I've started to learn C programming a bit and wanted to create a simple 2D console game. Let me first introduce you to the game level/map structure: ...

1
2 3 4 5
71