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.

learn more… | top users | synonyms

0
votes
0answers
7 views

Function that assigns names to a struct using strtok

I worked around using strtok function so to assign first name and last name to a struct PERSONNE from a char *names[] array. It ...
-1
votes
0answers
13 views

How to Make Words random in C? [on hold]

Suppose i have word apple in variable b like this char b[100]; b[]={a,p,p,l,e} How can i generate random string like this: ...
7
votes
2answers
89 views

Base64 encoding implementation

I am learning C and decided to make an implementation of Base64 encoding according to the info Wikipedia provides about it. My main question is: should I declare the index_table array inside the ...
1
vote
1answer
17 views

Matching patterns of characters

I was wondering if there are any significant improvements that could be made in order to make the program more concise or efficient, particularly in the findmatch ...
4
votes
4answers
318 views

Expanding compressed string

I wrote this for a problem in one of the online contest at hackerearth. Problem statement is: Input: The first line contains the compressed string in form a2b4h5a2 Expanding it ...
3
votes
2answers
54 views

BMP file writer

In my current project I'm writing a C function to write a BMP-File. Internally, the function is split up into three parts: write header, write info header, write data. In some of these functions I do ...
4
votes
1answer
121 views

Generate String with Random Consonants and Vowels in C

Replace all c / C / v / V in stdin with lower case, upper case consonants / vowels respectively. All other input is passed through. Anything that can be improved? ...
0
votes
1answer
39 views

Generate all permutations in C

I have written code for generating all the permutations in C as explained here. How can the code be optimized? Are there any memory leaks? ...
6
votes
2answers
206 views

Automation of array allocation in C

I recently have been working on moving from projects written in Java and C++ to C and realized that the lack of std::vector in C makes it a bit more difficult to ...
-5
votes
0answers
22 views

Segfaulting during XOR [on hold]

When running the above code, the program segfaults at *plaintxt ^= key;. I've thought about it and can only come up with, possible order of operations error with ...
3
votes
3answers
80 views

Natural merge sort in C

I have this C implementation of the natural merge sort: ...
-3
votes
0answers
44 views

What is wrong with my quicksort algorithm? [closed]

I tried writing quicksort algorithm recursively and using lomuto partitioning scheme. But there seems to be something gravely wrong with it. It works only for small inputs but takes forever for even ...
8
votes
2answers
59 views

Compiler for a minimal LISP dialect to run on the Java Virtual Machine

As the title states, this is a compiler written in C with a ruby build script that translates a minimal LISP dialect and spits out an executable jar file. I designed this LISP dialect and named it ...
0
votes
2answers
33 views

BMP writer in C

I recently wrote a BMP writer in C: bmpWriter.h ...
4
votes
1answer
34 views

A Generic Approach To Doubly Linked Lists

I've written a small implementation for doubly linked lists. While actually intended to be only used by me in subsequent projects, I wrote it as generically as possible. Maybe this'll be advantageous. ...
-1
votes
0answers
11 views

Forming a word parsing algorithm for a word search puzzel [closed]

I'm working on a wordsearch program in C that takes in a grid of chars with given dimensions that parses string chucks from each row, column, and diagonal directions and compares the chuck to a ...
-1
votes
0answers
37 views

Selection sort algorithm for a 2d char array in C [closed]

I am trying to make a selection sort algorithm for a 2d array in C (as the title says), the code compiles but unfortunately it does not sort anything. is there anything I can change that will make ...
2
votes
2answers
83 views

Removing comments from a C source file

I wrote this program to remove comments from a C source file, accepting a file name from the command prompt. Let me know if I missed anything or if there are any improvements that can be made in the ...
3
votes
0answers
37 views

Safe, fully standards-following integer abs in C

Here's a bit tricky one, because AFAIK there is no existing platform, where conditionally compiled part of the code would actually get included by compiler, so it is entirely up to the human review to ...
3
votes
2answers
233 views

C getline() implementation

I'm practicing my C coding and I wanted to implement my own version of the getline function in C for learning purposes. I'd like a review on coding style, ...
3
votes
1answer
35 views

Simple stack structure in C

I just started to learn C, and for practicing, I tried to implement a simple stack data structure, and I want to know if I'm making any mistakes, or how could I improve it: My stack.h: ...
3
votes
2answers
61 views

C Stack data structure

I have implemented a Stack data structure in C and I would like to know if there is something that could be improved. Stack using linked list: ...
3
votes
1answer
25 views

USACO TRAINING - Section 1.2 - PROB Transformations

I'm trying to improve my coding skills by going through the USACO TRAINING PROGRAM. I would like a review of my code for solving the transform problem. Here is the problem statement: A square ...
4
votes
1answer
36 views

YAGOP - Yet Another Generic Object Pool

While thinking about this question it struck me that one problem of linked data structures always seems to be loss of memory locality and performance could possibly be improved if all allocated nodes ...
8
votes
4answers
417 views

Custom memcmp function

I have written my own memcmp() function for learning purposes: ...
0
votes
1answer
34 views

Substring erase with certain pattern

For following input string: ...
6
votes
1answer
38 views

Robust scene manager

I made a simple scene manager in C99. I tried to make it readable, reusable and reliable. I would be grateful if you would help me to improve it. I want to use it for my upcoming OpenGL game. I think ...
2
votes
1answer
45 views

Maximum subarray problem solved with divide and conquer also for the all negative element case

Solving the maximum subarray problem with added cases of finding non maximum non contiguous subarray as well. I used divide and conquer approach and tackled the 'all negative' case by keeping a ...
3
votes
1answer
39 views

7-segment 4-digit display

Is there a better way to organize the methods within this program without compromising the clarity? Running through digits 0-9 with separate functions seems very bulky. ...
8
votes
4answers
950 views

Program to Check If string is Palindrome (in C) [closed]

Just wrote a program to check if a string is Palindrome. If that's true, return 1. Else, return 0. How can I improve it? ...
1
vote
2answers
86 views

Fibonacci heap in C - follow-up

(See the previous iteration.) I have incorporated some points made by ChrisWue and refactored my Fibonacci heap implementation: fibonacci_heap.h ...
1
vote
0answers
38 views

Measuring CPU frequency in *nix

I have this small function for reading the TSC (time-stamp counter) in *nix. Using it seems to report my CPU frequency more or less correctly. ...
2
votes
1answer
33 views

Project Euler #7 in C: find 10001st prime using something like Sieve of Eratosthenes

I've gotten a solution for Project Euler #7 in C (find the 10,001st prime). I came up with the very simple algorithm myself (from what I can tell it's similar, if not identical, to the Sieve of ...
3
votes
3answers
72 views

String Compaction Algorithm

I've been working on improving my C coding. I wanted to write two string algorithms: to trim white space from the beginning and end of a string to compact a string I have a few problems with this ...
5
votes
2answers
703 views

Reverse an integer, find the absolute difference, then reverse again

Intro For one of my university assignments we were asked to take an unsigned int, reverse its digits, find the absolute difference between the original and reversed, then reverse that, and you ...
1
vote
2answers
40 views

Program to let any user run a command

I have a script which can only be run by one specific user on a system. I need to let all users on the system have access to run that script and see the output. But there must never be more than one ...
1
vote
2answers
49 views

Linux C Port Knock Implementation

Compile with: gcc -std=gnu11 -o "portknock" "portknock.c" -lpcap I did this as a learning experience, and it actually ended up being something useful. I made a ...
2
votes
1answer
28 views

Menu Navigations

My friend requested a navigation menu for his code that he has since he didn't really know how to do it, so I had created one for him. I just wanted to get it reviewed since I'm a beginner with C and ...
3
votes
1answer
158 views

Fibonacci heap in C

(See the next iteration.) I have rewritten a Fibonacci heap implementation from Java to C. fibonacci_heap.h: ...
3
votes
2answers
43 views

Tree ADT implementation in C

As a learning exercise, I decided to implement a BST and add functionality to it slowly. I'd appreciate any feedback. I should also point out that I borrowed the template from the here. ...
8
votes
3answers
886 views

Replace spaces with '%20'

This is my attempted solution to Question 1.3 from "Cracking the Code Interview", 6th ed. Question: Write a method to replace all spaces in a string with '%20'. You may assume that the string has ...
2
votes
2answers
82 views

Find numbers between 1 and 10000 whose sum of digits are prime

I have the following C code that finds numbers between 1 and 10000 whose sum of digits are prime and save then to a file. ...
2
votes
2answers
49 views

C permutation generator

I am making a permutation generator in c. Any ideas how I can make it faster? ...
3
votes
1answer
39 views

Thread sync using conditional variables

Can you review the code? ...
4
votes
1answer
47 views

Singly-linked implementation in C

I'm a C++ programmer and thought I'd revisit the roots, so I scribbled something really quickly. I would appreciate input on how my C code is looking! slist.h ...
12
votes
9answers
884 views

Simple string inverter program

I am currently studying c programming, but I'm at a very basic level. So for practice I made a program that reads a string and inverts it. I want to know if the code is readable and how I can improve ...
1
vote
1answer
25 views

Server client for distributed system

This is the code I am using for a distributed system. The code will be used to allow the server to send parts of a (really big) document which will be processed by the connected clients. Please tell ...
3
votes
1answer
42 views

Singly linked list in pure C - follow-up

This is an update for this post. I fixed all style-issues from the comments, but still have a few questions left: Someone commented that my last post contained too many functions, which could be ...
14
votes
6answers
559 views

Counting numbers with specific digits

The challenge: Suppose you are inhabitant of a planet where 1, 7, and 9 are lucky digits. A lucky number for you is a number that contains only your lucky digits in it. For ex: 1, 79, 911, 9917 ...
2
votes
3answers
56 views

Singly Linked List in pure C

I recently learned about linked lists and here is my first try to write one in C. I know it's a lot of code, but I hope someone takes a look. Any tips memory allocation and improvements are welcome. ...