Skip to main content

All Questions

Tagged with
3 votes
2 answers
69 views

Reading a file into lines (benchmarking getline() vs mmap_memchr() vs mmap_getline() vs fread())

This is a follow-up to: Reading a file into lines with mmap vs getline. The actual names of the functions are not ...
Harith's user avatar
  • 9,462
7 votes
1 answer
232 views

Reading a file into lines with mmap vs getline

I required a function to read a file into lines for a text editor, and ended up with two routines. One uses getline(), and the other uses ...
Harith's user avatar
  • 9,462
5 votes
1 answer
112 views

Instance specific code generation

Disclaimer: I've asked this question before on Stack overflow and got a response that this place would be a better fit so I am copy pasting the question here. I've come up with two different ...
user1806687's user avatar
3 votes
3 answers
101 views

Parse program arguments of the form key=value

I have two proposals for parsing arguments: Method A ...
alirezaarzehgar's user avatar
2 votes
1 answer
161 views

C/C++ hash looking in flat database compared to PHP

I have a hash table which I would like to query as fast as possible. The hash table is stored this way : When I query a hash, I extract first 4 characters then use it to find the file. For instance a ...
James's user avatar
  • 41
3 votes
2 answers
370 views

Retry read/write until all bytes are transferred or error occurs

Currently I have a wrapper function for the read/write system calls, the purpose of which is to eliminate partial transfer ...
user avatar
0 votes
3 answers
114 views

Populate a color table in XCB

This function has 16 repeated calls to the same function, passing in the same handles to each: ...
Ignis Incendio's user avatar
2 votes
2 answers
93 views

Common Unit Testing Code – Follow Up

This question is a follow up question to the Common Unit Testing Code portion of my lexical analyzer questions. My primary concern is the code in the header file and the C source file that implements ...
pacmaninbw's user avatar
  • 24k
5 votes
3 answers
382 views

Ask the user a number between 2 and 20

Here is my attempt: ...
Zwettekop's user avatar
  • 125
4 votes
1 answer
452 views

Evaluating π using Monte Carlo methods - Serial vs OMP

I wrote this simple code for evaluating the π using Monte Carlo method. This is the serial version: ...
Ilmionome456's user avatar
7 votes
3 answers
4k views

malloc in main() or malloc in another function: allocating memory for a struct and its members

When initializing a struct in C, we can allocate memory inside the main function or within another function and return a pointer to the newly created struct. This ...
David's user avatar
  • 181
5 votes
1 answer
323 views

Two cross-platform implementations of getline in C

I created my cross-platform implementations of getline function in C. It takes different arguments and have different return values than 'original' ...
DeBos's user avatar
  • 525
5 votes
1 answer
320 views

Mouse control of a camera in an OpenGL program

Introduction I'm doing an OpenGL program in C. As of now I'm working on the 3D camera system and got the control right. Now I'm working on the mouse control. It works, but I have used two different ...
Cewein's user avatar
  • 153
1 vote
3 answers
95 views

Given a series of characters from stdin, print their squared integer ASCII counterparts

This program in essence is extremely simple, however, it can be written in many different ways. I'm a beginner at C and I've written it in 5 different variations (mostly differing in the use of ...
bool3max's user avatar
  • 189
1 vote
3 answers
546 views

Checking if a string is a palindrome

This is the code for checking if a string is a palindrome. The execution time, for sample cases, is 0.40358 seconds. What must be done to increase the performance? ...
user4641842's user avatar

15 30 50 per page