c

Are there any languages that fit the same niches as C?

Do any proposed, or implemented languages fit in the same (enormous) niche as C, with the intention of being an alternative, while maintaining all the applicability to OS, high performance, embedded and other roles? ...

declaration and definition

Still confused with declaration and definition in term of C: if a header file is like: #ifndef _BASIC_H_ #define _BASIC_H_ void test(); extern int i; //define or declare #endif and two source file f1.c and f2.c contain this header, then one source file need to define the variable "i". but if the header file is like: #ifndef _BASIC_...

how to know the path,where the errors and warnings are stored in eclipse

I have a doubt related to errors and warnings ........ For example i wrote a simple code in c (eclipse IDE) then i compiled. i got some errors and warnings in problem tab.This is the scenerio just think like this. My doubt is where is errors and warnings are stored (in my computer) file.I want to know location of the file (which inclu...

Dump memory of a process

Hi, When reading the /proc/$PID/maps you get the mapped memory regions. Is ther a way to dump one of this regions? $ cat /proc/18448/maps ...[snip]... 0059e000-005b1000 r-xp 00000000 08:11 40 /usr/local/lib/libgstlightning.so.0.0.0 005b1000-005b2000 r--p 00012000 08:11 40 /usr/local/lib/libgstlightning.so.0.0.0 005b200...

How to allocate a memory with execute permissions ?

I want to allocate a memory with execute permissions. So I use mprotect to change the permissions.. To get a page aligned memory I use a valloc function. void * temp = (void *) valloc(x); and then if( mprotect(temp, BLOCK_SIZE, (PROT_READ | PROT_WRITE |PROT_EXEC))) { exit(-1); } Now I want to add more memory to this allocated bl...

Number of bytes read by synchronous ReadFile.

Assume I have 1Mb file, file pointer is at the beginning of the file. I call synchronous ReadFile: ReadFile(Handle, Buffer, 1024, Result, nil); the call is succesful, no error occured. Is it possible that Result value (number of bytes read) is less than 1024 (number of bytes to read)? I think that is impossible for disk files, I am n...

Fast infoset or .net binary compression open source libraries

Hi, are there open source libraries implementing the fast infoset or the .net binary compression format? I'd need them for C, C++ and C# (including support for the .net framework, I'm not sure it natively supports the binary compression). The final goal is that of compressing xml files with a fast algorithm available for a wide range of...

Cannot return and assign char array to pointer in C

char *test = "hello"; test = change_test("world"); printf("%s",test); char* change_test(char *n){ printf("change: %s",n); return n; } im trying to pass a 'string' back to a char pointer using a function but get the following error: assignment makes pointer from integer without a cast what am i doing wrong? ...

value of natural logarithm

I want to find value of In(x) without using math.h function I am following this formula which I found in my math book: log(m) base e = 2[ (m-1/m+1) + (1/3) * (m-1/m+1)^3 + (1/5) * (m-1/m+1)^5 + ... ] Here is my code: i = 3; logx = 0 ; ty = (x-1)/(x+1) ; do { logx = logx + ty ; tty = ty ; ty = (ty * ((x-1)/(x+1)) * ((x-1)...

Extract a tar.xz in C/C++

I am writing a program that downloads tar.xz files from a server and extracts them in a certain place. I am struggling to find a away of extracting the tar.xz file in the certain place. I am using Qt so a more Qt-way of doing it would be useful, but I don't really mind. ...

Why both utf-16le and utf-16be exists? endianness efficiency - C

I was wondering why both utf-16le and utf-16be exists? Is it considered to be "inefficient" for a big-endian environment to process a little-endian data? Currently, this is what I use while storing 2 bytes var locally: unsigned char octets[2]; short int shotint = 12345; /* (assuming short int = 2 bytes) */ octets[0] = (shortint) ...

Is this C implementation of Fisher-Yates shuffle correct?

Hi all - Here's a C implementation of Fisher-Yates that I want to use in a deck-shuffling routine. Am I doing this correctly (n = length of array)? Note: The do-while loop attempts to correct for the modulo bias (see here). It adds a bit of overhead to the procedure and could be eliminated if you don't care about the low-bit bias. voi...

Crash Analysis on Linux

What is the best way to analyze crashes on Linux? We expect to build the software and deliver a release version to testers. The testers may not be able remember how to reproduce the crash or the crash may be totally intermittent. They also will not have a development environment on their machines. The software is written in C/C++ and c...

What techniques are available to test if a character string is all spaces?

char *p = " woohoo"; int condition = /* some calculation applied to p */ /* to look for all 0x20/blanks/spaces only */ if (condition) { } else { printf("not "); } printf("all spaces\n"); ...

What are diferences between FFmpegs AVcodec, x264 and WebM VP8, for encoding N frames? (please provide code support.)

What are differences in C code that should be written in FFmpegs AVcodec, x264 and WebM VP8, for encoding some amount of generated frames? So Idea here is to collect simple array of video_encode functions containing: Encoder setup, Frames generation and frame by frame encoding. simple. just on codec level (no special containers involved...

How to use enum within a struct in ANSI C?

Following code has to be used in the main-function, but I don't know how it is used. struct SomeItem { enum {MOVIE, MUSIC} itemType; union { struct Movie* movie; struct Music* music; }; }; this struct is used in a dynamic linked list with previous/item/next pointer, but I don't know how you can set the enum...

C optimization question

Hi, I'm wondering what is the fastest way that I can write some code. I have a loop which executes an add on some ints. The loop will be executed many, many times and so I've thought of making comparisons to check if any operands are zero, so they shouldn't be considered to be added, as follows: if (work1 == 0) { if (work2 == 0) ...

How to memset() memory to a certain pattern instead of a single byte?

I am facing today with a problem where I need to change memory to a certain pattern like 0x11223344, so that the whole memory looks like (in hex): 1122334411223344112233441122334411223344112233441122334411223344... I can't figure out how to do it with memset() because it takes only a single byte, not 4 bytes. Any ideas? Thanks, Boda...

Correctly sizing Alsa buffers, weird API

I'm currently working on a project that requires me to do some sampling with Alsa. I'm trying to configure correctly everything but I'm stuck on how to correctly size my reading. There are two primitives that seem to be interesting for my task: snd_pcm_hw_params_get_period_time snd_pcm_hw_params_get_buffer_size The name of the first ...

Allocate array from command line parameters

I am working on a small C application and I am capturing a value from the command line. I would like to capture the value and use it to initialize an array. Here is what I'm trying to do. int main(int argc, char* argv[]) { int option = atoi(argv[2]); int values[option]; ...... } I am getting a compilation because my opt...