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

Racket FFI for looking up the group and passwd databases

This is my first foray into FFI. It annoyed me more than it surprised me to learn that the definition of struct passwd is not portable; I've stuck with the GNU ...
-5
votes
0answers
27 views

Why does the result depend on where we write the return statement [migrated]

The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of ...
2
votes
1answer
30 views

How can I modify my graph traversal algorithm to increase efficiency?

I have an adjacency matrix "A" which I am using to represent a graph for a social network. Each node of the graph represents a person's name, and I am storing people's names in an 2-d array (the index ...
-3
votes
0answers
15 views

msgsnd erro: invalid argument for IPC program [closed]

These are my client and server codes for message queue. The required function is supposed to be quite simple, client sends a number to the server, which the server receives and then sends back a sort ...
-4
votes
0answers
19 views

Input in python3 [closed]

Can a program in python, take input in the same line like in C, where we can can use scanf to take input differentiated by space? And, how. In C, ...
2
votes
3answers
37 views

using system calls to compare text files

I am trying to make a script that compares 2 .txt files. It works, but I wanted to double-check if there's something I missed about these system calls (since I'm new at this). Is there any ...
-3
votes
0answers
33 views

How can i solve this using C language? [closed]

The user inputs digits, character by character, separated by spaces. Function from digits constructs and returns a number (int). If no digit is entered, the entry continues. Entering ends when the ...
2
votes
2answers
67 views

Getting time since Unix epoch on both Windows NT and *NIX systems

The following snippet of C includes implementations for both Windows NT and POSIX-compliant systems to get the time (with microsecond resolution) since the Unix epoch. In the case of Windows NT, the ...
5
votes
1answer
104 views

Simple BASIC to Simpletron Machine Language compiler in C

I implemented a compiler that compiles a dialect of BASIC known as SimpleBASIC into Simpletron Machine Language to be run by the Simpletron simulator. I wrote the manual for the SimpleBASIC compiler ...
-2
votes
1answer
33 views

Data management for buses and and employees [closed]

I am relatively new so any help would in improving this and future codes. The code involves basic file management for two different files, one for buses and another for the employees and I am not very ...
8
votes
4answers
484 views

Checksum a Game Boy cartridge

I wrote a program to insert a checksum into a Game Boy cartridge. Here is a spec of the cartridge header, but I'll include the relevant information here, as well. The header checksum is defined as ...
4
votes
3answers
126 views

A dice roller in C

I am learning C and, for learning purposes, I implemented a dice roller. It uses arc4random(3) for random number generation, as I couldn't find something better. It works both interactively, if no ...
7
votes
2answers
162 views

Simpletron simulator in C

I implemented a Simpletron simulator in C for learning C. Simpletron is a virtual machine invented by Deitel for his books. Simpletron runs programs written in the Simpletron Machine Language, an ...
3
votes
1answer
26 views

Convert a binary string, with each char separated by spaces, into a normal C string and print

This code is a purely for-fun project and it comes from this challenge at freeCodeCamp. This is simply an algorithm challenge which is usually meant for JavaScript, but I decided to perform in C. It ...
2
votes
2answers
76 views

Sieve of Eratosthenes optimisation

I'm implementing Sieve of Eratosthenes by working with multiples of 30 and comparing it to multiples of 3 from a previous answer code for multiples of 30: ...
8
votes
2answers
176 views

Tron game on Wii / GameCube

I implemented the following Tron cycle game so that it can be run on GameCube / Wii devices (quarantine...). Indeed, there exist many tools (I rely on devkitPPC) and I thought a Tron game would be an ...
1
vote
2answers
69 views

Title Case function in C

I've written the following function in C which shall take as input a character array (decayed to a char * of course), and mutate the string into a title-cased string in the form "this is a string" -> "...
6
votes
3answers
279 views

Simple text based game in C

After sticking with the same handful of languages for years, I decided to learn C. I've written a guess the number game, where it generates a random number based on the difficulty level, and then you ...
3
votes
2answers
75 views

Count distinct colors within a bounding rectangle

I implemented a program that does the following: Consider the positive quadrant of the xy plane. A colored point is a triple (x,y,c) where x is its x-axis coordinate, y is the y-axis coordinate, ...
13
votes
4answers
2k views

C Program which compares software version strings

I wrote the following C program to compare software version strings. Please provide any general feedback you'd like, but with special focus on error handling decisions, user input validation/...
3
votes
1answer
47 views

C backtracking Sudoku solver

I wrote this program in C to solve a given Sudoku puzzle (represented as 2D array) using backtracking algorithm. How can I make it more efficient, maybe faster and more C-onic? This is my first post ...
3
votes
2answers
78 views

Basic 'char' Stack implementation in C

...
1
vote
1answer
41 views

Traffic Light which revolves around Serial Communication

Assignment description This is the improved code for a question I've posted earlier. I'd like to receive feedback on an assignment which I'm currently working on. I have to make two traffic lights ...
2
votes
1answer
42 views

Feedback on Traffic Light which revolves around Serial Communication

Assignment description I'd like to receive feedback on an assignment which I'm currently working on. I have to make two traffic lights which allow traffic to run smoothly. I'm using a master Arduino ...
3
votes
1answer
22 views

Check shell programs for portability

There are lots of shell programs that have /bin/sh as interpreter, yet use some features that are specific to bash or other popular shells. I have written a little ...
3
votes
1answer
53 views

C Singly Linked List Implementation

I'm a C Beginner and I am looking for feedback on my implementation of a singly linked list. The code is split between list.c and ...
1
vote
0answers
28 views

Helper for matching players in a video game [closed]

Terminology: Host - Spectator and summoner of players involved in the 1v1 matches Player - A player who is participating in the 1v1 matches Phantom - A player summoned for a 1v1 (present in the ...
2
votes
3answers
72 views

Counting the number of digits with a recursion algorithm in c

I'm learning recursion and I think that I can finally wrap my head around it. I had to write a program that given an integer would print out its number of digits and I wanted to know if it is ...
-3
votes
2answers
127 views

Good use of goto?

I think I may have come across a good use of goto in my code. From when I started programming in C it was driven into me that goto was akin to summoning the devil himself and use of goto should be ...
3
votes
3answers
517 views

Stack implementation using linked-list

typedef struct Stack { char v; int x; int y; struct Stack* next; } Stack; Above is my stack struct. ...
4
votes
1answer
57 views

C pointer based growable stack rev2

Following on from my previous question: C pointer based growable stack I have made some improvements (hopefully!) based on the very helpful comments and suggestions. I have checked that the stack can ...
7
votes
3answers
1k views

C pointer based growable stack

This is my first attempt at writing a C program, it a generic stack that can grow accordingly. It appears to work correctly, however I am worried that is just a fluke and I could be doing something ...
-2
votes
1answer
31 views

Selection sort in C

...
2
votes
1answer
69 views

Permutation code in C

I am pretty new to competitive programming. It took me almost 3 hours to make this, initially I started with 4 for loops and then to make it scalable for sizes bigger than 4, I decided to turn this ...
0
votes
0answers
25 views

Evaluating a Definite Integral, kindly check

The code below does not deal with any numerical-integration or anything related to it — just the basic rule in evaluating a definite integral of the form Ax^2 + Bx + C. I would love to hear from you ...
5
votes
2answers
91 views

x86 Single Stage Bootloader

I'm learning OS development and have written a single stage bootloader that loads the kernel, enters to protected mode and finally jumps to the kernel. I'll very appreciate any feedback and ...
3
votes
3answers
49 views

Raspberry PI switching from Soft Access Point to WIFI client

I am relatively new to C language and Linux systems I would like some feedback/review. The main function of the code is to read the dhcpcd file looking for the 3 lines and then either adding/removing ...
17
votes
5answers
2k views

Compare version numbers

I am wondering if there is any way to meaningfully shorten the chain of conditionals used here to compare two versions. struct VERSIONCODE represents a version ...
7
votes
5answers
2k views

Generic linked list implemented in pure C

Recently i added such generic list in github and i would like to get some feedback. Here is a link to the code in github: https://github.com/MartinChekurov/Generic-Linked-List GenericList.c ...
2
votes
2answers
105 views

Console application for bank management

I am new to C. I tried to make a bank management console application. I want some one to review it for advice to enhance and develop my coding skills. This is what the program does with the inputs: <...
7
votes
3answers
125 views

Bit shift 256 bits

I have a working solution to my problem, but I'm less than satisfied with the result, both when it comes to style and performance. In short, I need to be able to shift 256 bits of data, say an array ...
0
votes
1answer
34 views

Code to write a C template file [closed]

I am writing code to write a C template file; the executable takes two arguments (main) <file name> and ...
1
vote
1answer
57 views

Macro to generate an enum and an array of strings

Often when I find myself working with magic number enum values and I want to know what they represent, so I create an array of strings in order to print out their label. This macro automates that ...
6
votes
1answer
63 views

K&R - The C programming language Exercise1-12

I am working through the K&R and just finished exercise 1-12 and below is my solution. Exercise1-12: Write a program that prints input one word per line. ...
13
votes
4answers
1k views

Light task-processing systems with zero dependency for Linux systems

I made a prototype for a task processing systems. Architecture Worker - is a entity that is processing one-by-one tasks for the same processor. Processor - (also: executable, app) executable file (...
4
votes
1answer
56 views

Minimalist context compressor

I am working on an implementation of the minimalist compression method. The method is based on context modeling, followed by a simple entropy coder (Golomb-Rice coder). The context model uses a single ...
9
votes
4answers
2k views

Simple hashing algorithm

TL;DR: The algorithm receives a string as input, allocate another string to be the final digest, and start working on them. For each char on the digest (a null character on a first moment), it XORs it ...
0
votes
0answers
33 views

Format raw bytes in hex and ascii in manner like Wireshark does in pure C

This function formats raw buffer output in manner as Wireshark and many others does: ...
2
votes
2answers
42 views

Removing nodes from a linked list

This is my second iteration of a function to remove all nodes containing value 'x'. The previous iteration is here. This function takes as input the head of a list and has to delete all the nodes ...
2
votes
4answers
98 views

Removing nodes with a given value from a linked list

Is this a good way of removing all the nodes that contains a value x? This function takes as input the head of a list and has to delete all the nodes that contain a given value taken. If there is ...

1
2 3 4 5
60