Tagged Questions

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

-3
votes
0answers
9 views

Creating UIImage from buffer returns nil [on hold]

I'm trying to darken UIImage by grabbing the CGImage, getting each pixel and subtracting 0xa from it, then saving each pixel to a new buffer. But when I try to load that buffer back as an image, the ...
0
votes
0answers
18 views
0
votes
0answers
13 views

Chess in C: Negamax implementation works but sometimes doesn't spot mates in 1 [migrated]

I implemented negamax with alpha beta pruning and quiscence search and it seems like it works... except for sometimes the computer lets me mate in 1, even though there were moves that it could've done ...
8
votes
3answers
199 views

Red Black Tree Implementation

I would like some feedback on my red black tree implementation. Anything is fine. I've debugged this and it seems to be working fine, however I may have missed something. Basically, this is a red ...
3
votes
1answer
17 views

Find binary sequences with low peak sidelobe level of autocorrelation function

I would like to find all binary sequences from the specified range, which has low peak sidelobe level of its autocorrelation function. Here is solution (this is simplified version of the real code) ...
4
votes
2answers
26 views

Chained hash table implementation

While reading a data structure book, I have implemented a chained hash table. I want to share the code with you and get your opinion about it. chained_hash_table.h ...
-3
votes
0answers
30 views

Project euler #7 with c [on hold]

i wrote these codes for question.it can be compiled but when i run it,i can only see a black screen. thank you for your helpings. ...
-1
votes
0answers
29 views

How to make random number generate new numbers each time? [on hold]

This program is supposed to replicate the game higher or lower. A number is chosen and the user must guess if the next is higher or lower. I cannot get this to work, the number always stays the same ...
-4
votes
0answers
21 views

Cannot debug the Segmentation Fault [on hold]

cursor went into DFS method but it is not coming out of DFS method and the error message shown is : segmentation fault(core dumped) file input.txt contains : ...
7
votes
3answers
159 views

Linked list C implementation

I'm reading a data structure and algorithm book in C. I have implemented a generic single linked list in the C programming language, and I want to know your opinion on my implementation: ...
-3
votes
1answer
47 views

Function to count unique colors in bmp [closed]

This function is supposed to work: ...
-2
votes
0answers
20 views

Sorting Singly Linked List by String Length [closed]

This is the only problem in my code, when I try to run it and I add more nodes in my list it says STATUS ACCESS VIOLATION. I know this is the only problem since when I comment out the code, my ...
6
votes
2answers
107 views

Generating 'Decent' numbers

While solving a problem from HackerRank, though it's aneasy one, I wrote this big program. Not sure if recursion is applicable and hold good but to me it looked like it isn't. However when I run the ...
1
vote
2answers
48 views

“The Love Letter Mystery” - storing and comparison of strings

The problem goes like this. Change the strings provided by user to form palindromes. To do this, 2 rules are: (a) Reduce the value of a letter, e.g. Change 'd' to 'c', but cannot change ...
7
votes
3answers
111 views

Simple shell in C [closed]

I am just getting started with C and made this simple shell to test my understanding of some basic principles. The shell reads commands from standard input, forks itself and executes the command. How ...
4
votes
3answers
69 views

Finding strings inside of other strings in order in C

A question on Stack Overflow recently intrigued me to the point of me implementing the functionality in C. Can you critique this algorithm and tell me what is good and bad about it? This program will ...
2
votes
2answers
124 views

Function to get the most frequently appearing pixel

What i have so far is a nice and rapid algorithm for finding the pixel dominant from bmp image. I am not sure how to make it to work.. i though it works, but the program freezes. ...
2
votes
1answer
37 views

Binary Search in C

The standard C library function bsearch wasn't giving me correct results, apparently. So I decided to implement a binary searching function in place of it. It ...
1
vote
1answer
36 views

Trajectory optimizations

Here's a function doing some trajectory optimization in the following manner: ...
6
votes
3answers
72 views

Singly Linked List Implementation in C

I'm preparing for an interview soon, and I've written the following linked list implementation from scratch. This is all self-taught, and I'm still working on my C. I feel that the implementation is ...
4
votes
4answers
120 views

String case reverse function in C

This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Besides documentation, in particular, any thoughts on the type ...
5
votes
4answers
42 views

Trimming fgets(): strlen() or strtok()

After a successful fgets(buffer, ...), it is often desirable to trim a potential End-of-Line \n. Of the following 2 methods, ...
5
votes
4answers
212 views

Character permutations - Revisited

Several hours ago I posted this question about Generating character permutations in Python. User rolfl said that my main problem was not using the right tool for the job, as Python is interpreted it ...
7
votes
3answers
515 views

Concatenate two strings

I am learning C and wrote a function to concatenate two strings in C. Please let help me improve it. ...
5
votes
1answer
37 views

Converting decimal integers to a string representation in an arbitrary base between 2 and 26

This code takes an integer and returns a string representing the value in a different base. The value for the base can range between 2 and 26. I have had someone already look over this code and they ...
4
votes
2answers
97 views

Minimum Spanning Tree using Prim's algorithm

I have implemented a Minimum Spanning Tree using Prim's Algorithm. Could someone give some about some improvements for code structure, conventions, performance, etc? ...
4
votes
4answers
831 views

*Code for fake UI

While I was coding it, I got a better idea, but I continued because I can not compare both of those ideas, because they are different. The idea of that function is to make your fake ui-building ...
3
votes
1answer
64 views

Applying scalar multiplication to matrix

This is one of my first programs in C. Please review and help me improve it. I create a matrix and apply scalar multiplication on it. Then I print the result. ...
-5
votes
1answer
49 views

Count percentage of audio samples exceeding a threshold

I have this practice question that I have an answer to: In this stage of the project, you will identify any "danger" spots, in which the SPL is greater than or equal to 80 dB (the value above ...
13
votes
5answers
267 views

Fastest way of removing a substring from a string

Taking a break from my C++ series, I recently reviewed the code in this question. I ended up writing my own separate derivation of the function so that I could remove all of the substrings from a ...
3
votes
1answer
46 views

Function for rendering custom fonts

I have a function that converts any normal true-type font to my own font file .bff That function works correct and am not going to post that function for that matter (the function is also only ...
6
votes
2answers
183 views

Trim a string to a given start and end

Are there any other more exotic ways ... or is this one just good? ...
3
votes
1answer
89 views

Example String Class in C

I wrote this small example piece of OOP being implemented in pure C. I wanted it to be reviewed for the following points: Portability Performance And especially Usability "How does it look" ...
2
votes
2answers
36 views

Merge all files in a directory with a specific extension

I come from Python, with a bit a FORTRAN and Matlab some years ago. I'm trying to learn C. My first attempt at a program is one to merge all the files in a directory with a specified extension ...
4
votes
2answers
44 views

Lopsided Trees and Recursion

The original problem is: Define the height of a binary tree to be the number of nodes in the longest path from the root to a leaf. The empty tree is considered to have height 0. A node is ...
8
votes
3answers
561 views

Randomized response generator for number-guessing game

I am currently learning C and playing around with the rand() and if/else statement. This ...
4
votes
1answer
52 views

Convert an `int` to a C string with size limitation

Creating a textual version of an int to save as a C string to a buffer that is all ready allocated and maximum allowable size is determined seems common. Thought ...
2
votes
1answer
51 views

RFC PS Rasterizer Library API

We've got the basic functionality of using my postscript interpreter, xpost, as a library. I'd like to solicit some feedback from the community on the API setup. ...
1
vote
1answer
86 views

Performance critical optimization routine with many arguments

A possibly similar question has been closed, but I'll give it a try anyway. A performance critical part of MATLAB code, a trajectory optimizer, has been moved to C (subroutine ...
8
votes
1answer
169 views

Logical shift with signed numbers

I am going through the Coursera course The Hardware/Software Interface and because it has already ended, I would not be able to get any feedback on the code. The assignment is: LogicalShift: ...
5
votes
2answers
75 views

Example of a Multithreaded C program

In answering password cracker in c with multithreading, I ended up writing a sample in C, which is not my forte. Is there anything that I missed which should have been included in a responsible ...
3
votes
2answers
98 views

Writing strings to a file

This opens a file and writes 5120 times a string to it, and if the file doesn't exist it creates a new file. The name of the file and the string are chosen randomly. I would like to know if there is a ...
6
votes
3answers
135 views

Byte swapping functions

I recently programmed some byte swapping functions. As a special I did a function which can convert an entire int array. I please you to look at the following aspects: portability performance ...
3
votes
1answer
54 views

Implementing a linked list

I am studying data structures at the moment, so I want to see if there is anything wrong with my implementation of linked lists in C, after I checked Implementing an ArrayList. Header ...
4
votes
3answers
128 views

Implementing an ArrayList

I implemented ArrayList functionality in C as follows: ...
6
votes
1answer
69 views

MicroC task switching

My background for this review is a university course in embedded systems using MicroC and this question. Now my program appears to run ok, but I'd like to know what you think can be improved or if the ...
-1
votes
1answer
55 views

ArrayList implementation in C [closed]

Although I know I can use calloc then realloc to make a dynamic array in C, and that I also need a variable to keep track of the ...
7
votes
3answers
165 views

Validating lines in a file using certain specifications

I have written a program which basically reads a file named "data.txt" line-by-line. As a line is read, it validates the line with a certain specification. If the specification is met, it will ...
3
votes
0answers
45 views

Parallel accumulated sum in OpenCL

This is my first relevant code in OpenCL. Please, let me know if I'm doing something wrong in a logical level (i.e., I guess it can crash in situations?) or accounting for performance (bottlenecks, ...
8
votes
2answers
596 views

Simple calculator

I created my first program in C: a simple calculator. I want to know if it is possible to make this code more effective. Is it, for example, possible to change the calculator function so that I don't ...