Hello guys,
Recently an interviewer asked me about the types of buffers. What types of buffers are there ? Actually this question came up when I said I will be writing all the system calls to a log file to monitor the system. He said it will be slow to write each and every call to a file. How to prevent it. I said I will use a buffer an...
OK, so I don't sound like an idiot I'm going to state the problem/requirements more explicitly:
Needle (pattern) and haystack (text to search) are both C-style null-terminated strings. No length information is provided; if needed, it must be computed.
Function should return a pointer to the first match, or NULL if no match is found.
Fa...
Hi,
I tried loading C shared library .so in Python using ctypes.CDLL class (Linux). Here is the link to which tells what I did. As I see the documentation it says CDLL class assumes that function returns int types. I've a doubt here what if I need to return variable of type other than the int type from a function in C?.
And to what exte...
I am having a total mind blank on this at the moment.
I have a cube (voxel) that is defined by a centre point and a width, height and depth of 1.
If I have a vector with an origin from the centre of the box (E.g. (-0.7,-0.7, -0.7)) how do I calculate the point at which the vector intersects the outside of the box?
EDIT: The box is alwa...
I want to use the git's malloc and realloc wrappers in my code for OOM(out of memory) conditions. Here is its code:
void *xmalloc(size_t size)
{
void *ret = malloc(size);
if (!ret && !size)
ret = malloc(1);
if (!ret) {
release_pack_memory(size, -1);
ret = malloc(size);
...
I'm searching a fast (specially the p^n mod g operation, should be implemented with montgomery) big integer library. I know there is GMP but GMP is LGPL which doesn't fit my requirements.
I tried http://www.acme.com/software/bigint/ and tried to optimize the modpow in there. But do to the fact that the data is stored with base 2^32 it i...
I want to extract every audio channel in a quicktime movie with the QuickTime-API. That means if the file has 5.1 surround, i want 6 audio files in the end.
But at the moment I don't know how to manage that. Until now I have:
OSStatus err = noErr;
MovieAudioExtractionRef extractionSessionRef = nil;
Boolean allChannelsDiscrete = true;
in...
Hello. I've been reading questions on Stack Overflow for a few weeks now... this'll be my first question.
So recently I've looked into making C access/manipulate a C++ class. I understand that ideally one shouldn't compile components in C and C++ separately under normal circumstances, but this isn't an option at the moment.
I looked in...
I have a c code about 1200 lines long and i want to convert it into matlab. is there any software or website where i can do it.
...
At the moment I am considering whether or not to rewrite a programming language interpreter that I maintain in C++. The interpreter is currently implemented in C.
But I was wondering, is the primary implementationbecause, certainly, people have made versions of many interpreters using a language other than the one used by the original a...
I'm using a library (ANet) which is written natively in C and I am interfacing with it using C# via a small subset wrapper dll which i've made in C and statically links to it.
The library (ANet) has a DllMain which simply tracks the number of references to it (so "Process attach" and "Thread attach" counts) but it seems to go into the ne...
Hey,
I need to generate a path string from a number (in C)
e.g:
53431453 -> 0003/2F4/C9D
what I have so far is this:
char *id_to_path(long long int id, char *d)
{
char t[MAX_PATH_LEN];
sprintf(t, "%010llX", id);
memcpy(d, t, 4);
memcpy(d+5, t+4, 3);
memcpy(d+9, t+7, 4);
d[4] = d[8] = '/';
return ...
Possible Duplicate:
What does unsigned temp:3 means
I'm learning some kernel code, and came along the following line (in linux 2.4, sched.h, struct mm_struct):
unsigned dumpable:1;
What does this mean?
...
Hello, I need to store a graph for the map of a game inside a game server written in C.
The graph has ~200 nodes and 3 kinds of edges that can connect two nodes (these three kind can also overlap: a node can be connected by 2 edges of two different types for example). The maximum degree of a node is something like 5-6 nodes.
What I wou...
char *a=NULL;
char *s=NULL;
a=(char *)calloc(1,(sizeof(char)));
s=(char *)calloc(1,(sizeof(char)));
a="DATA";
memcpy(s,a,(strlen(a)));
printf("%s",s);
Can you plz tell me why its printing DATA½½½½½½½½■ε■????How to print only DATA?? Thanks
...
I have following code
int wordLenght = 256, arrayLength = 2, i = 0, counter = 0;
char **stringArray = NULL;
stringArray = calloc(arrayLength, sizeof(*stringArray));
for(counter; counter<wordLenght; counter++)
stringArray[counter] = calloc(wordLenght, sizeof(stringArray));
while(1)
{
printf("Input: ");
fgets(stringAr...
/* It is not entering data into the third scanf() statement .*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
struct book
{
char name;
int pages;
float price;
};
struct book a1,a2,a3,a4;
printf("Enter data into 3 books\n");
scanf("%c %d %f",&a1.name,&a1.pages,&a...
What's the best/recommended way to copy data between a byte array and an integer in C? Currently I'm using memcpy, which doesn't feel right to me. A sample of the sort of thing I'm doing is below.
struct alpha {
unsigned char byte_array[20];
}
void function(struct alpha *st) {
unsigned long num;
/* Do some stuf...
In c++, setw function is used to set the number of characters to be used as the field width for the next insertion operation. Is there any function in C, I mean, in standard c library, which does the same thing?
...
Hello everyone! For school I have to program a merge sort using only pointers.
I've tried almost everything, but I can not get it working.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define num_elementi(array) (sizeof(array)/sizeof(array[0]))
void selsort(int arr[],int n);
void swap(int * a, int * b);
void print(int a...