Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
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.
15
votes
2
answers
38k
views
Convert between date/time and time-stamp without using standard library routines
I am trying to implement two simple convertors: date/time to time-stamp and vice-versa, without any dependencies on time library routines (such as localtime, mktime, etc, mainly due to the fact that s …
14
votes
Tic-Tac-Toe program in about 250 lines
| %c | %c\n", board[0][0], board[0][1], board[0][2]);
printf("-----------\n");
printf(" %c | %c | %c\n", board[1][0], board[1][1], board[1][2]);
printf("-----------\n");
printf(" %c | % … c | %c\n", board[2][0], board[2][1], board[2][2]);
/*
if there is a winner
{
print the winner
break;
}
*/
}
As you can see, I left it for you to check if there …
6
votes
Accepted
Find smallest prime number greater than given n
You can implement function isPrime to test primality in a little more efficient manner:
int isPrime(int n) // assuming n > 1
{
int i,root;
if (n%2 == 0 || n%3 == 0)
return 0;
ro …
3
votes
Accepted
Counting the longest increasing subsequence in an array of integers
Here is one comment about the readability of your code.
/* 1 means not used */
int used_flag[seq_size];
I allowed myself to change the "use" to "used", because it is more grammatically correct.
No …
3
votes
My own malloc() function in C
One additional comment on top of what's already mentioned in previous answers.
Using sizeof(void*) instead of 8 will make it:
More efficient (memory wise) on 32-bit platforms
More robust on futur …
2
votes
3
answers
313
views
Calculate the square root of the sum of the squares of the prime factors of an input number
I need to find ways to improve the runtime performance of the following piece of C-code.
I want to increase RANGE to around 1G, and still complete the execution within a reasonable time. …
2
votes
Phonebook implementation in C
Do not ignore compiler warnings:
Function run: variable c is unreferenced.
Function error_check: not all control paths return a value. …
1
vote
Accepted
Red Black Tree Implementation
Implementation Issue:
I would call strcmp(k, root->key) once:
int cmpval;
if (root == NULL)
{
...
}
else
{
cmpval = strcmp(k, root->key);
if (cmpval < 0)
{
...
}
else …
0
votes
Accepted
Calculate the square root of the sum of the squares of the prime factors of an input number
Based on @MOehm's second answer, I have managed to increase RANGE to 4 billion:
Sieve Interface:
#include <limits.h>
// Defined by the user (must be less than 'UINT_MAX')
#define RANGE 4000000000
…
-4
votes
1
answer
115
views
Verify FIFO dequeue algorithm
I have a FIFO queue of packets, which maintains:
Push index
Pop index
Count
I would like to assert my dequeuing algorithm:
if (push_index >= (count-i))
pop_index = push_index-(count-i);
else
…