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
1 vote
1 answer
108 views

A small timer in C

I needed to make a timer to profile small programs a while back. My use wasn't for a major project or mission critical code or anything even remotely close to that, just for personal learning ...
tijko's user avatar
  • 638
1 vote
2 answers
647 views

Binary Search Tree insert while keeping track of parent for node to be added

This question has a follow up question: Binary Search Tree insert while keeping track of parent for node to be added - iteration 2 I am implementing a red black tree for fun and am wondering how I ...
httpNick's user avatar
  • 125
1 vote
4 answers
155 views

Copy/remove characters "in place" without causing UB from strcpy

I am writing a portable library function, which is a generic "remove characters" function. Language standards used are C11 and MISRA-C:2012. TL;DR: it should either remove all occurrences of a ...
Lundin's user avatar
  • 4,660
1 vote
1 answer
1k views

Enforce exclusive order of four processes using semaphores

I am on the learning curve of C and its capabilities. Below I have tried to create 4 individual programs where the execution is always in order (program 0,1,2,3). About the program Program #0 is ...
user3337714's user avatar
1 vote
1 answer
1k views

Printing a singly linked list with time complexity O(n) and space complexity O(sqrt(n)) [closed]

My aim is to write a method which prints contents of a singly linked list in reverse order with time complexity \$O(n)\$ and space complexity \$O(\sqrt{n})\$. The best I could come up with is to store ...
Sagar B Hathwar's user avatar
1 vote
2 answers
654 views

Recursive way to find inorder successor

So far I have attempted to find the inorder successor through recursion and it seems to be working right. Can someone review the code and give suggestions? ...
srinivas's user avatar
1 vote
2 answers
1k views

Univariate polynomial multiplication using Doubly Linked List

A univariate polynomial is a polynomial over a single variable, and in the following discussion when we say polynomial, we mean a polynomial in a single variable. You are given two polynomials – ...
envy_intelligence's user avatar
1 vote
2 answers
818 views

Bisection method for finding the root of a function

For those who aren't familiar with the bisection method for finding the root of a function (i.e. finding where \$f(x) = 0\$) the basic idea is: Take a function \$f(x)\$ and an interval \$[a,b]\$ If \$...
galois's user avatar
  • 289
1 vote
1 answer
567 views

Makefile to build library

I'm starting with make, and I made my first makefile to build my project. I don't know if it's the best way to do it or not, so I share with you my makefile to get your opinion on it: Directory ...
KarimS's user avatar
  • 391
1 vote
1 answer
51 views

Two index computations differing in execution time

Code I have the following piece of code ...
embert's user avatar
  • 445
1 vote
1 answer
103 views

Read file directly - simplified

In order to read a whole file as a string using standard libraries you have to allocate memory, terminate the string, determine size of the file and size of each element. This could happen with ...
Genis's user avatar
  • 281
1 vote
1 answer
70 views

Memory searcher function test

This is part of the project I started just now. It is a function that returns the offset address of a first occurrence of a string match into a given range of memory blocks. ...
Edenia's user avatar
  • 1,568
1 vote
1 answer
135 views

Print all subsets and permutations of a string

The following code is designed to accept a string from the user that is at most 5 characters long. It will then find each possible substring of the string and print all possible permutations of each ...
user avatar
1 vote
2 answers
354 views

Speeding up Hexadoku

I have serious problem with my Hexadoku (16 x 16 , a - p) solver. I'd like to run the program in under 2 seconds but my solution solves it in 10 seconds. Native Code: ...
Banksy's user avatar
  • 21
1 vote
1 answer
2k views

Minimum Spanning Tree using Prim's algorithm and an indexed minimum priority queue

I have written some basic implementation of a Minimum Spanning Tree using a indexed minimum priority queue. For the implementation of the Priority Queue I used Sedgewick's Tutorials. However, it seems ...
yadav_vi's user avatar
  • 496
1 vote
1 answer
349 views

Base64 encoder optimization

Base64 is a widely used encoding mechanism to allow arbitrary binary content to be transferred as printable text. This program is designed to take binary file as input and produce a Base64-encoded ...
Carrybubbles's user avatar
1 vote
3 answers
43 views

Determining coefficient in geometric progression

For an assignment at Uni we had to code a program that takes numbers as input and determines the coefficient if they form a geometric progression once you declare EOF (ctrl+z). If the user inputs a ...
Nikolai Naidenov's user avatar
1 vote
1 answer
3k views

Freeing a binary tree data structure in C

I have this function that I hope to be a good alternative to the recursive (thus performance expensive) approach. ...
Amr Ayman's user avatar
  • 853
1 vote
1 answer
528 views

Creating an insert at front function for a circular doubly linked list

I have only been working with C for a couple of months and I think I have a pretty good function to insert a node in the front of the circular doubly linked list. I have tested in adding several ...
Aaron's user avatar
  • 955
1 vote
2 answers
391 views

Displaying data as binary in C with bitmasks

I wrote a program to display data in memory as binary and it worked. (It gave me immense sense of satisfaction and joy to see this work. I guess this happens to newbies who are just testing the waters)...
Bellyjean's user avatar
1 vote
1 answer
221 views

Determine how many bits are in a floating point value [closed]

I'm writing a program which determines how many bits are in a floating point value (this will be run on Unix). ...
user3478869's user avatar
1 vote
2 answers
3k views

Binary search on cstrings

This implements binary search on an array of cstrings. One thing I'm wondering about is it faster or slower to pass a variable as const i.e. len. Also ...
Celeritas's user avatar
  • 911
1 vote
1 answer
148 views

Square free Integer

I am an amateur programmer and I tried coding this problem using the TurboC++ IDE (though my code is in C), but the site's compiler throws a "TIME LIMIT EXCEEDED" error. How can I optimize my code ...
S Raghav's user avatar
  • 113
1 vote
1 answer
3k views

Sorted trie implementation in C

I wanted to store some dictionary data (key/value pairs of strings) in C, and decided to use a trie. I found what looks like a good implementation here, along with some nice notes. In this ...
Dagg's user avatar
  • 4,531
1 vote
1 answer
158 views

Basic Linked list

I am learning C from K.N. King and at ch-17, I covered linked list and wrote a code to add data in the ascending order in the linked list which is opposite to found in the book (In the book, it store ...
Ashish Rawat's user avatar
1 vote
1 answer
6k views

split up a string into whitespace-seperated fields

I am trying to improve my C skills, and I hope someone might be able to provide me with some feedback on the following code. I avoid strtok function intentionally. ...
Fihop's user avatar
  • 1,025
1 vote
1 answer
6k views

SPOJ Problem 2 - Prime Generator

I'm trying to solve this problem. After a couple of tries, this is what I pulled off: ...
Monzir's user avatar
  • 111
1 vote
1 answer
564 views

Parsing an XML configuration file for network monitoring

I want to simplify this C code into different functions: ...
user1285928's user avatar
1 vote
1 answer
231 views

Simple text file encryption and decryption

Short introduction; recently I've completed a basic course on C but other than that I have no programming experience and I am a total beginner. As a practice project and to practice reading from and ...
Reslashd's user avatar
1 vote
1 answer
58 views

Revised C Doubly-Linked List

I have revised the implementation I originally posted here. Thank you all who responded; I took your comments to heart. Please let me know if you have any additional feedback. Here are some notes to ...
user129393192's user avatar
1 vote
1 answer
330 views

Virtual memory manager in C

Virtual Memory manager that has functions, mappage, unmappage, remappage If the physical ...
runningupthatroad's user avatar
1 vote
1 answer
122 views

Code for setting all child controls to the default message font on Windows

If you aren't aware, if you hand-code a GUI with the Windows API you will find your controls look quite ugly by default due to their font. Running this code: ...
Govind Parmar's user avatar
1 vote
1 answer
83 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-...
Mike's user avatar
  • 299
1 vote
1 answer
75 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 ...
Zombie Chibi XD's user avatar
1 vote
1 answer
32 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 ...
Martzy's user avatar
  • 33
1 vote
1 answer
117 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 ...
Mark's user avatar
  • 449
1 vote
1 answer
58 views

C code for discovering numbers with interesting/beautiful/symmetric properties

Below is a C code that generates 1000 random positive integers, for each number we check primality, palindromic property, and the square root of the sum of the digits. The purpose is to find/discover ...
Redsbefall's user avatar
  • 1,132
1 vote
1 answer
184 views

A C WinAPI program for showing the color of the screen pixel pointed to by mouse cursor with clipboard support - follow up

(See the previous question.) Now I have incorporated some suggestions by Barmak Shemirani. See what I have: ...
coderodde's user avatar
  • 28.1k
1 vote
1 answer
107 views

Another generic dynamic arrays in C

Wrote this (and others not here) as an exercise to explore how generics could be implemented in C. Question -- if I were to support out-of-band error setting, how would that look like for ...
IncandescentNonsense's user avatar
1 vote
1 answer
70 views

CLI Generator & Parser

I have written a module that allows the developer to generate a CLI and parse given arguments. I am fairly new to C and would love to hear feedback on my code to improve it. All feedback is welcome ...
conaticus's user avatar
  • 125
1 vote
1 answer
165 views

What are the issues with implementing the Shortest Job First algorithm?

I wrote a program that implements the Shortest Job First (SJF) scheduling algorithm. The total number of processes is read directly from the standard input, following that for each process to specify ...
Mark's user avatar
  • 449
1 vote
1 answer
84 views

Recursively delete directory using relative filesystem calls

I made this function to recursively delete a directory and its contents, because using VLAs to concatenate paths is more susceptible to Stack Overflow and is probably slower. ...
user avatar
1 vote
1 answer
143 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 ...
user786's user avatar
  • 145
1 vote
1 answer
47 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 ...
user252524's user avatar
1 vote
1 answer
303 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 ...
MindSwipe's user avatar
  • 235
1 vote
1 answer
224 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, ...
user avatar
1 vote
1 answer
345 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 ...
user786's user avatar
  • 145
1 vote
1 answer
292 views

Validate Empty Sudoku: Multi-Threaded Solution

The problem is that we have an unsolved sudoku board, and we want to validate it, we need to check each column, row and sub-square. Here we represent a empty cell with -1. My idea was to create a ...
AKRA's user avatar
  • 155
1 vote
1 answer
42 views

tokenize char array with PolarSSL library

I'm trying to perform a decryption operation using RSA. I'm using the PolarSSl library. I have a char array key[] that contains RSA private key like the following, <...
user45698746's user avatar
1 vote
1 answer
37 views

A simple C WinAPI program for terminating processes via process image names - follow-up 4

(See the previous version here.) What's new get_last_err_msg renamed to MyGetLastErrorMessage The caller to ...
coderodde's user avatar
  • 28.1k

1
70 71
72
73 74
80