c

Extract a line of C code using perl based on filename + line number

Hi, I'm looking to extract a statement of C code given the filename and linenumber where it begins. I can't, of course, just take the line, as I could have something like: foo(i, j, "this is ); \ ", k); as the example indicates, I also can't look for the next ); either, which would make it fairly simple. Is there anything out...

What is the common denominator XML library across Linux and Windows for parsing XML in C or C++?

I want to parse some XML in a C and C++ app. This app is deployed to Windows and Linux. What is an XML library that is likely to be installed on many Linux distributions and is readily available on Windows? From my samples of Linux distros, libxml2 seems to be fairly common, but is there a more common xml library? ...

Array Compression Algorithm

I have an array of 10345 bytes, I want to compress the array and then decompress, kindly suggest me the compression algorithm which can reduce the size of array. I am using c language, and the array is of unsigned char type. Rephrased: Can someone suggest a general-purpose compression algorithm (or library) for C/C++? ...

assigning a char buffer to an array of pointers

Hello, gcc 4.4.4 c89 warning assignment makes integer from pointer without a cast **devices = device_buff; warning: value computed is not used *devices++; I get the above warnings with the code below. What I am trying to do is get an input from the user. And assign that char array to an array of pointers. So my array of pointers will...

modified depth first traversal of tree

I got this question in an interview with amazon. I was asked to perform a depth first traversal of a tree, without using recursion or stack. I could use a parent pointer for each node, as a part of the structure, but nothing else other than that.(for ex, a "visited" variable" or anything). Please suggest me an algorithm. ...

c string compare vs hash compare

I need to compare a string to multiple other constant strings in c. I am curious which is faster, to hash the string I am going to compare and compare it to all the other constant string hashes or just compare the strings as strings. thank you in advance thank you for the answers I am going to be doing many comparisons. can anyone give ...

what is the best IDE to develop large c/c++ apps on Linux

Possible Duplicate: C++ IDE for Linux? what is the best IDE to develop large c/c++ apps on Linux which will provide capabilities to debug/search references etc. ...

Gigaflops of a processor

I discovered my computer has NVIDIA CUDA Technology and I want measure the power of processing, in CPU and GPU. Instead of searching for a program to do this, I want have a deeper understanding of how it works. What kind of code (C/C++) I need? ...

What's an efficient and simple way to store a data structure?

I want to write a parser for NBT (Named Binary Tags) structures. The format is represented like this: TAG_Compound("hello world"): 1 entries { TAG_String("name"): Bananrama } And in memory (or the file it's stored in) as hexadecimal view: 0000000: 0a 00 0b 68 65 6c 6c 6f 20 77 6f 72 6c 64 08 00 ...hello world.. 0000010: 04 6e 61...

Accessing the underlying struct of a PyObject

I am working on creating a python c extension but am having difficulty finding documentation on what I want to do. I basically want to create a pointer to a cstruct and be able to have access that pointer. The sample code is below. Any help would be appreciated. typedef struct{ int x; int y; } Point; typedef struct { PyObject_HEAD ...

Avoiding Denial of Service attack

Hello guys, when I use recv from windows sockets does using recv can lead to denial of service attack ? If it waits for data forever? So what is the best way for solving this (alarms ?) Thanks & Regards, Mousey. ...

Why does C++ support memberwise assignment of arrays within structs, but not generally?

I understand that memberwise assignment of arrays is not supported, such that the following will not work: int num1[3] = {1,2,3}; int num2[3]; num2 = num1; // "error: invalid array assignment" I just accepted this as fact, figuring that the aim of the language is to provide an open-ended framework, and let the user decide how to imple...

producer-consumer problem:posix mutex got locked twice when using condition variable?

Following code is only to show how to use condition variable to synchronize threads(one producer and many consumers) as exercising. See the line for code 'usleep(100);'.When I comment this line,two consumer threads seem got the mutex locked at the same time after the producer thread exit,and then wait on 'cond',this raise race condition...

confusing on pointer and array

We have int a[5]={10, 20, 30, 40, 50}; I would like to know how does the following two code segment do? int *ptr = (int *)(&a+1); int *t = (int *)(&a -1); If we have printf("%d %d %d \n", *(a+1), *(ptr-1), *(t+1)); What should be the result? ...

MIN and MAX in C

Where are MIN and MAX defined in C, if at all? What is the best way to implement these, as generically and type safe as possible (compiler extensions/builtins for mainstream compilers preferred). ...

C extension: <? and >? operators

I observed that there was at some point a <? and >? operator in GCC. How can I use these under GCC 4.5? Have they been removed, and if so, when? Offset block_count = (cpfs->geo.block_size - block_offset) <? count; cpfs.c:473: error: expected expression before ‘?’ token ...

Simple Objective-C (applies to C) console program to convert fahrenheit to celsius and visa versa

Hey everyone, I am writing a simple console application in Objective-C but I have heard that this coding may be loosely applied to some C as well, so I wanted to make that clear. I am having a slight problem however, when I run from the Debugger in Xcode, for some reason, my program does not wait for user input, it just rolls right on t...

My program is not asking for the operator the second time

#include<stdio.h> #include<stdlib.h> main(){ int b,c,r,d; char a; while(1){ printf("Enter the operator\n"); scanf("%c",&a); if(a=='+') d=1; if(a=='-') d=2; if(a=='&') d=3; if(a=='|') d=4; if(a=='.') d=5; printf("Enter the operands\n"); ...

How to extract a number/byte from an array in C ??

Here i have written a code which produces next 8 numbers from sequence. int next_exp_data(unsigned long long int expected_data) { int i=0; unsigned long long int seq_gen_value=1976943448883713; unsigned long long int temp_data[10]; temp_data[0]=seq_gen_value; for(i=0;i<10;i++) { printf("%llu",temp_data[i]); putcha...

How to render text in C (android)?

Hi experts, I am developing a program drawing text on screen using android NDK in C native code. Could you please tell me how do I render the text? Thank you. Best regards Michael ...