2022 Developer Survey is open! Take survey.

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
1 answer
40 views

improved "tee" utility

We have modified the tee program with your suggestions from the previous pull request. Did I implement well? I would like to optimize the program even more, what ...
user avatar
  • 179
0 votes
0 answers
12 views

daemon in a producer-consumer

The daemon program is associated with a message queue with a predefined key, to be blocked later when waiting for messages. The two programs implement a producer-...
user avatar
  • 179
3 votes
1 answer
206 views

Kosaraju's algorithm in C simple implementation

I am wondering can I please get some feedback for my simple implementation of the Kosaraju algorithm. More specifically how I de-allocate the things I allocated using ...
user avatar
  • 359
1 vote
2 answers
43 views

Hash game in C optimization

I developed this hash game in C for my college, but i need to optimize this code, can you help me? it works well, but I need it to be a little more organized and faster, the rand function is the only ...
user avatar
0 votes
0 answers
16 views

pending signals using the sigpending() function

I used the sigpending () function in the next program to check the signals waiting at 1s intervals and display their numbers, then it ends with ...
user avatar
  • 1
2 votes
1 answer
41 views

Changing the attributes of a file

I wrote a program that changes the attributes of a file. How can I make the program more efficient? Please find program problems. How can I improve the program? ...
user avatar
  • 51
0 votes
1 answer
28 views

Integer array to string

This function creates takes an int * buffer and creates a neatly formatted string (useful for printing the contents of an array). Is the code easy to follow? Is it ...
user avatar
  • 155
3 votes
2 answers
435 views

Implementation of the "tee" utility program

How can I optimize the program? To make it more optimal? The program should be more optimal in terms of source code, compiled executable size, memory usage, speed, bugs etc. Please criticize the ...
user avatar
  • 179
2 votes
2 answers
48 views

Basic Stack Operations using Linked List in C

I have made a few functions for some basic stack operations using linked lists. Please review my code and suggest some ways to increase its readability. I would also love to hear ideas on how to make ...
user avatar
3 votes
2 answers
58 views

Calculate average of each line of input

I made a program that will loop and calculate the average of the input given by the user. There are no problems here. I just want to know if there is a better way to do this, or a way to optimize this ...
user avatar
0 votes
0 answers
17 views

Simple C11 mutex implementation using `_Atomic`

I'm trying to learn concurrency and synchronization using C programming (C11). As a learning exercise, I wanted to quickly implement a mutex I appreciate that this code is almost trivial, but I would ...
user avatar
2 votes
2 answers
99 views

another attempt to implement the tee command

I implemented the tee command from linux. The program implements the -a option Reads standard input until end-of-file, write a ...
user avatar
  • 179
11 votes
3 answers
1k views

Toggle 2 LEDs using a timer XMEGA-A3BU Xplained

I’m currently taking an online embedded programming course. This was our 4th programming assignment. The device is Microchip(Atmel) XMEGA-A3BU Xplained Development Kit, Mfr. Part Number: ATXMEGAA3BU-...
user avatar
  • 18.2k
3 votes
1 answer
48 views

display processes children

The following program uses a parent program to determine the PIDs of multiple child processes. A function is called to return them to a dynamic vector (with the children's pids, but also the elements ...
user avatar
  • 179
1 vote
1 answer
37 views

Longest Increasing Subsequence of Rectangles

Background I was looking at some programming Olympiads the other day, and I found this ACM-ICPC Ukraine 2013 pdf. The part I am working on is Problem D, which consist of finding out how many rectangle ...
user avatar
0 votes
3 answers
99 views

Convert from decimal to binary and octal

I wrote a program that implements an algorithm that converts from decimal to binary and octal Please criticize my implementation. What else can I do to improve? ...
user avatar
  • 179
5 votes
0 answers
44 views

Menu Parser in C

This is a simple program that parses a menu specification and creates a menu tree. Why? I want to create a menu application, where the user can select an entry in the menu, and either a submenu can ...
user avatar
  • 151
3 votes
3 answers
94 views

tee: copy standard input to both stdout and a file

I implemented the tee command from linux. The program also handles the -a option for adding text to the end of a file if it ...
user avatar
  • 179
4 votes
1 answer
88 views

Case-insensitive sort in C

I wrote a sorting program so that if the optional argument -i is present then the sorting should be done without taking into account lowercase / uppercase letters. ...
user avatar
  • 179
5 votes
0 answers
65 views

A POSIX getdelim() and getline() implementation for MSVC

Tired of always having problems in reading arbitrary length lines from file under Windows, I tried to write a POSIX getdelim() and ...
user avatar
0 votes
1 answer
29 views

OAuth implementation for Puredata

I am managing an OAuth implementation for Puredata (Pd), which is written in C. OAuth can accept RSA keys, but Pd cannot send messages with newlines, so placing private keys will come as a list of ...
user avatar
  • 155
0 votes
0 answers
26 views

Lexer for english words in C

I implemented a simple lexer for English. What it's supposed to do is scan English text (not large text, just about one or two sentences at a time), split words at spaces, line breaks, mark each word ...
user avatar
  • 269
3 votes
2 answers
54 views

change file attributes on a Linux file system with chattr

I am reading the book The Linux Programming Interface and I have reached the exercise in which the implementation of the chattr command in C is required. I would ...
user avatar
  • 51
5 votes
2 answers
487 views

CSV to TSV converter in C+yacc+lex and a Makefile

This is Comma-Separated Values to Tab-Separated Values converter written in C, with yacc(1) and lex(1). I'm remembering how to use yacc (the first (and last) time I used it was while reading «The UNIX ...
user avatar
4 votes
1 answer
95 views

Arbitrary Length Input in C

From scanf() to fgets(), we need to first specify the maximum length of the string input, due to which input gets a limitation, ...
user avatar
3 votes
1 answer
77 views

Simple tokenizer in C

I implemented a simple tokenizer. Would love to hear your feedback on code style, best practices: ...
user avatar
  • 269
2 votes
0 answers
52 views

Bellman-Ford algorithm implementation

I have used an adjacency list to represent the graph. This implementation is based on the procedure given in the book 'Introduction to Algorithms'. ...
user avatar
1 vote
1 answer
24 views

C lang CGI form update

Have posted here a while ago, I've read the answer and now I tried to apply the observations. This is the new code, I hope is it better than before. One thing I'm not sure if I used it properly is ...
user avatar
  • 33
5 votes
2 answers
157 views

Stack implementation in C programming Language

I have tried to implement a Stack and associated functions in C, in order to understand the data structure better. Just wanted to know what do you think about my code overall. Furthermore, I am using <...
user avatar
0 votes
1 answer
22 views

n an array of N elements calculate its mean and count the number sub array of N-2 elements that have same mean

The below code is getting TLE error i.e Time limit Exceeded Error. I am finding it difficult to solve it without using nested for loops.Can someone tell a faster logic or can improve this code. ...
user avatar
1 vote
1 answer
40 views

AES implementation in C

I've implemented AES encryption in C to get more familiar with the language and to understand how encryption works better. I understand this code is unsuitable for actual cryptographic use and I'd ...
user avatar
  • 113
2 votes
1 answer
31 views

C lang CGI form/string handle

Started playing with C and CGI forms. Is this code ok? Can it be improved/optimized? If I fill user with "user" and password with "pass" input in takelogin is ...
user avatar
  • 33
0 votes
2 answers
70 views

Slice function for C

I am trying to create a non-generic slice function. I want a 'view' not a copy. The scan_from arg is so that successive calls ...
user avatar
  • 503
2 votes
1 answer
66 views

General Purpose Makefile

This is my "general purpose" makefile that I wrote with the following objectives in mind: Ready to use (copy/paste in a simple directory and it works out of the box) Flexible (easy to add ...
user avatar
  • 23
-1 votes
1 answer
79 views

Brainfuck interpreter in C, looking for improvements on the looping functionality [closed]

I've just started to get into PL design and made a simple Brainfuck interpreter. Although it is functional, I don't feel too confident on the execution, particularly the implementation for loops, I ...
user avatar
2 votes
1 answer
109 views

implementation of the `mkdir` command with `-p` parameter in C

I wrote a program that implements the mkdir command with the -p parameter to create the parent directly if it does not exist. My ...
user avatar
  • 1
2 votes
2 answers
92 views

Linked-list in C without typedefs and globals?

I took RosettaCode's implementation and tried to create something useable (editing their wiki as I go to give-back): ...
user avatar
  • 503
0 votes
2 answers
54 views

Department change management utility

I was wondering on how to make the execution time faster. Is there a way to make it faster with this method or do I need to make with another method? If someone have any solution please help me. ...
user avatar
3 votes
1 answer
50 views

Quickly read numeric input

Do you have any criticisms or corrections or improvements? I need to read only numbers(and this numbers could be from 0 to 1000000) ...
user avatar
1 vote
1 answer
71 views

multiply matrices

I wrote a program that calculates the multiplication of two matrices (of compatible dimensions) where each element of the resulting matrix is ​​calculated by a separate thread. Each thread calculates ...
user avatar
  • 1
3 votes
1 answer
79 views

An attempt to use the sigpending function

I wrote a program that uses the sigpending () function. The program returns blocked or pending signals. My question is, what else could I improve or what problems ...
user avatar
  • 1
5 votes
1 answer
408 views

C: Reverse individual words in a string

I have been practicing C and I wanted to reverse each word in a string. I wrote this code and although it works, I am not happy with my solution. It requires twice the length of the original string to ...
user avatar
  • 359
2 votes
1 answer
56 views

Linked List Implementation in C. Looking for feedback

I am new to C programming and DSA. This is my implementation of a Linked List. I am looking for feedback and tips to improve the code design. ...
user avatar
  • 21
0 votes
2 answers
77 views

Encryption and Decryption in C

I have written a program in C, which encrypts and decrypts a c-styled string (const char *) and print the result to stdout. It ...
user avatar
7 votes
1 answer
281 views

Pseudo-Generic Array Stack in C

I have implemented an array based pseudo-generic stack in C using macros. The code works fine for all data types. Is it a good idea to implement such a data structure using macros? array_stack.h ...
user avatar
3 votes
1 answer
67 views

Traditional vs. bidirectional Dijkstra's algorithm in C

I have this CLion project on GitHub. It constructs a directed, weighted graph consisting of 100 thousand nodes and 500 thousand directed arcs, picks two random nodes, and computes the shortest paths ...
user avatar
  • 25.3k
5 votes
3 answers
64 views

Creation & pixel manipulation of 24 bit TARGA

I wrote this code to get familiar with structs in C. It allows the creation and exporting of a 24 bit TGA image and changing the color of individual pixels. My concern is the ...
user avatar
3 votes
0 answers
99 views

Two-dimensional arrays in C

I have a bit of trouble with two-dimensional arrays in C. I want to pass such an array to a function accepting a pointer to pointers. I figured no way of really passing the array itself. Furthermore, ...
user avatar
  • 31
0 votes
0 answers
29 views

Modifying a Linux touch driver to poll I2C data instead of using interrupts

I managed to modify the st1232.c touch driver to poll I2C data from the touch controller, instead of using interrupts. This way I don't need an extra interrupt wire. On the other side I am now using ...
user avatar
  • 101
5 votes
1 answer
200 views

C smart string implementation using preprocessor

I have wrote a smart string container implementation for use in my application, but as I'am not such professional C programmer I have doubts about is I'am did it right and is there ways how to improve ...
user avatar
  • 53

1
2 3 4 5
74