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.
0
votes
0answers
3 views
C program reading from a file into structure not quite working
I have written a program that should be reading stuff from a file into a struct. (The file contains an element and its density) My program reads the stuff, but when I have to swap the lines and make ...
1
vote
0answers
9 views
Arduino sketch running on Arduino Mega as a web server
I have Arduino Mega with Ethernet shield mounted on top running as a web server.
It reads temperature, humidity, rain or not and pot soil moisture and then displays on web page. Can you please review ...
6
votes
1answer
89 views
List directories (with information)
For part of a project, I was given this directive:
The “ls” command will require you to use directory functions to list
out what the filenames are in the directory. Functions required to
make a ...
4
votes
4answers
136 views
Counting nucleobases in a nucleotide
This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Calculating protein mass ruby. The repository with all my up-to-date solutions so far ...
3
votes
0answers
25 views
Parsing my JSON-like format in C
For the past few weeks, I've been using the wonderful cJSON to add content to my game. But recently, I got tired of JSON's verbosity so I decided to roll my own format called SON (Simple Object ...
2
votes
1answer
42 views
Calling a function every 40 second inside a while loop
This code invokes a function for every 40 seconds inside a loop. I am doubtful about this condition:
if ((time_left <= 0 || time_left > interval))
Is only ...
3
votes
1answer
41 views
Service to keep variables in memory
I'm a beginner C programmer. I want to write a program with the following characteristics:
The program is essentially a 'daemon' or a 'service' that sits in the background doing nothing except ...
3
votes
2answers
95 views
Keeping bank account records using a struct
Can you just shoot me some ideas on how to better structure the program and also if you notice any big no-nos at first glance? This is certainly not production code, it is my first attempt at a data ...
-6
votes
0answers
76 views
Modelling a Rubik's Cube [on hold]
I'm trying to represent Rubik's Cube in C but I'm facing problems. One of the most obvious ways is to use a 3x3 array to represent a side. However, since I'm enumerating a large number of permutations,...
3
votes
3answers
62 views
Simple random string generator in C
It is just a simple piece of C code that generates random lenght random HEX srings. Any ideas how this code can be improved?
...
1
vote
2answers
64 views
Massive file sorting algorithm
I was trying to sort a massive file of successive chars in C. I did some research and found a few file sorting algorithms that look the same. Their main idea is to read an amount of data to memory, ...
3
votes
2answers
56 views
Simple mutex and conditional variable signal in C
I'm new to multithreading in C so I made a toy program that uses a mutex and a conditional variable to communicate between two threads. do_work performs a task ...
-4
votes
0answers
26 views
C program not working - Working with functions and arrays [on hold]
I'm trying to modify a program (using C99 standard) that used 2 global variables (one of which is an array) which are used by multiple functions and what I have to do is bring them within the main ...
-1
votes
0answers
20 views
Implementation of strnicmp in c [closed]
Iam trying to understand the Implementation of strnicmp from linux source code.
http://lxr.free-electrons.com/source/lib/string.c
I just tried to implement it without extra variable c1 and c2 and ...
-3
votes
0answers
18 views
Bugs in program [closed]
I am completely new in C and have been given a code to review and find bugs in. Any help would be highly appreciated!
...
-5
votes
0answers
22 views
-6
votes
0answers
30 views
5
votes
2answers
77 views
Dining Philosophers variation in C
This is a variation of the Dining Philosophers Problem. The task is to coordinate several students inside a gym. All students try to obtain their desired training weights from a shared weight rack. ...
4
votes
1answer
39 views
Decoding 32-bit MIPS instructions
For a homework assignment I've been given the task of parsing out information from an 32-bit MIPS instruction. (For more information on the instruction formats, see here). The instructor has provided ...
3
votes
1answer
40 views
Linked list to manage a class
I'm working on a linked list to save the information of students. I can insert anywhere on the list, delete and sort it. Now i'm reviewing the code to try to simplify it somehow. I don't know if the ....
-2
votes
2answers
70 views
Two-letter word dictionary - array index implementation
Here is the code for a two-letter word dictionary (example: aa) using array indexing:
...
2
votes
1answer
120 views
Remove comments from C-like source code
I am working on the problem of removing comments from C-like source code. Here is my code in Python 2.7, and if anyone could advise improvement areas (especially performance), or any functional bugs ...
1
vote
0answers
25 views
Generic natural merge sort a linked-list in C
I have a .h file that implements my "generic" by defining LINK_* beforehand. This is an implementation of natural merge sort on doubly-linked lists using log n ...
6
votes
1answer
41 views
Counting sort implementation in C
I've just implemented counting sort in C and would like to hear your opinions on it. As I'm usually being rather picky when rating other people's code, please go ahead and be picky, too -- I will try ...
4
votes
1answer
26 views
Show the results of linked list operations in sequence
I'm working on a basic linked list programs. In this program I can insert elements at the beginning, at the middle (after one specific element) of the list and at the end. I also can delete a specific ...
4
votes
1answer
48 views
Pool allocator in C
This is an allocator that is used in replace of malloc if you do a lot of rapid, but small allocations on the heap. I wrote this for reducing system calls to improve performance. It works, but I've ...
0
votes
3answers
173 views
compute_ranks function
I've been working on optimizing such as loop unrolling, is there anything I can do to optimize this code to make it run faster/in less cycles?
...
1
vote
0answers
38 views
File manager project (creates and prints file)
I just finished my very simple and beginner-friendly C project and wanted to hear your thoughts and opinions about ways to improve it or something.
...
4
votes
3answers
187 views
0
votes
2answers
38 views
Adjacency list from scratch
Here is my code for implementing an adjacency list from scratch. I would like to get feedback from the experts for optimization.
...
3
votes
0answers
33 views
Linux performance using multi-threads (vs one thread) and ssh message
My server receives requests in one thread and responds in another. I am using thread pools of pthread-s for both receiving and sending. The performance is not that bad, however...
When I am doing the ...
1
vote
1answer
52 views
4
votes
1answer
57 views
Checking if CPU supports rdrand
My goal with this bit of code is to check if my processor supports rdrand and, if not, execute some other random number generating function. To check if ...
3
votes
2answers
44 views
Bubble sort code
I tried avoiding nested loops and usage of too many variables. This is up for review and comments.
...
2
votes
1answer
40 views
Beginning C BST implementation
I'd really appreciate if I could get some feedback on the following code with regard to security, efficiency and possible uncaught errors. Personally I feel the ...
3
votes
1answer
47 views
List abstraction using array
Following this reference, below is the list abstraction implementation using array,
...
0
votes
1answer
29 views
Quadratic probing and hashing - search for words in text files
I created a program for a college class. After I got it working, I wanted to improve it. As a beginner, it is probably a mess.
Description
It uses a HashFunction ...
2
votes
1answer
32 views
Securely Delete All Drive Data
When giving away or selling a PC, one should be careful not to send personal data with it. I'm in such a situation and was using dd if=/dev/urandom of=/dev/sdb bs=8M...
1
vote
3answers
60 views
C strlcat implementation
I have to reproduce some basic functions in C and one of them is strlcat.
After reading the man and testing the strlcat from <bsd/string.h> library, I wrote ...
4
votes
2answers
66 views
Red light, green light… kinda
For an assignment I had to create a client and a server that communicate over a well known FIFO. The server is required to use three threads to serve the client, managed by a semaphore.
The code was ...
3
votes
1answer
61 views
Win32/C: Notepad wrapper that automatically converts Unix line endings to Windows line endings
At my work we're dealing with a lot of PHP files written by a third-party company and sometimes we want to "quickly look at" these files in Notepad rather than having to open up a full IDE.
The ...
3
votes
1answer
48 views
Waiting for input with timeout
When my program begins, I want to allow the user to hit a key to enter debug mode for one of the modules. Many of the solutions (involving alarm(), in particular) ...
3
votes
1answer
54 views
Concatenate variable number of strings
I am learning C on my own. This is not an assignment. I am trying to implement a function that takes a variable numbers of strings and concatenate them in a new string. It works, but I feel it is not ...
5
votes
1answer
26 views
Short header file for safe CLI input handling in C
Proper input handling is a pain in the butt in C, so as part of a project of mine, this header is used to handle reoccurring command line input tasks such as input loops, reading lines and tokenizing ...
1
vote
0answers
31 views
A-Eye: Analysing Eye tracking Data
I'd appreciate your advice.
data file: https://drive.google.com/open?id=0B_UEM0TEmA_yeHJBZ0dzbV9Ca2c
...
1
vote
2answers
65 views
4
votes
1answer
33 views
String tokenizing with arbitrary token count in C
I am building a small program for input handling so I can conveniently parse lines and tokenize strings. The token handling works right now but I have to malloc a lot in the main() to make it work. ...
1
vote
1answer
33 views
Select comparison function for sorting based on type information
So I'm working on a patch for the python interpreter where you go through the list and look at the types of the elements and try to use optimized special-case comparison functions that are much ...
5
votes
4answers
116 views
Factorials, loops, break and professional code
The program below correctly calculates factorials, until the limit for an unsigned long long integer is exceeded.
My question has to do with loops and exiting ...
3
votes
2answers
48 views
Config file to struct in C
I have a struct OPTS which contains a few chars and char[]s. I also have a file opts.cnf ...