c

Is there a code formatter/beautifier usable from Netbeans

The code formatting option that Netbeans has is not customizable enough for C/C++. For example it has options to add spaces to binary operators, but I cannot specify which. So putting it ON results in: (a == b && b == c) and putting it OFF results in: (a==b&&b==c) What I would ideally like is: (a==b && b==c) Any suggestions on h...

doing math on files.

I am writing a program in C for file compression. The method i am trying to use involves doing math on the file as if it were one long number. Can anyone recommend a bignum library that would not try to do all of that in ram, but rather let me do math with file pointers. any help would be appreciated, thanks in advance. ...

How to check if "set" in c

If I allocate a C array like this: int array[ 5 ]; Then, set only one object: array[ 0 ] = 7; How can I check whether all the other keys ( array[1], array[2], …) are storing a value? (In this case, of course, they aren't.) Is there a function like PHP's isset()? if ( isset(array[ 1 ]) ) ... ...

Why does the following code raise a SegFault. c(Linux)

This a code that would reverse the data of a document and save it in the same document itself. However I am getting a Segmentation Fault.Please Help,I don't know why it gives a SegFault. #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <fcntl.h> #include <string.h> #include <unistd.h> int main (int argc,char* argv[...

Numeric value of digit characters in C

I have just started reading through The C Programming Language and I am having trouble understanding one part. Here is an excerpt from page 24: #include<stdio.h> /*countdigits,whitespace,others*/ main() { intc,i,nwhite,nother; intndigit[10]; nwhite=nother=0; for(i=0;i<10;++i) ndigit[i]=0; while((c=getchar())!=EOF) ...

WinApi Base Services tutorial?

I need to make application which gathers basic data about system, like OS version, processor & memory type, data about installed programs... Application will be written in c and will work on Win Server 2000 and 2003. So first thing on my mind was WinApi, but i can not find any tutorials for these things, every tutorial i found is about U...

When a third-party C function returns a pointer, should you free it yourself?

There are many functions (especially in the POSIX library) that return pointers to almost-necessarily freshly allocated data. Their manpages don't say if you should free them, or if there's some obscure mechanism at play (like returning a pointer to a static buffer, or something along these lines). For instance, the inet_ntoa function r...

Javadoc-like documentation for C/C++ libraries?

Is there such a thing as Javadoc-type documentation available for C/C++ libraries? ...

Collision detection between two general hexahedrons

I have 2 six faced solids. The only guarantee is that they each have 8 vertex3f's (verticies with x,y and z components). Given this, how can I find out if these are colliding? ...

Detect NUL file descriptor (isatty is bogus)

The following C file gives a bogus result when NUL is piped to it: int main() { printf("_isatty = %d\n", _isatty(0)); } the result is: C:\Users\Edward\Dev\nulltest> test.exe < NUL _isatty = 64 I'm pretty sure NUL (aka /dev/null) is not a terminal device! So I need to detect in another way whether or not the file descriptor corres...

using fflush(stdin) every time i use scanf.

Possible Duplicates: Using fflush(stdin) I am not able to flush stdin. As scanf() does not absorb the new line entered,isnt that a good idea to use fflush(stdin) each time i use scanf()? ...

How to display hexadecimal numbers in C?

I have a list of numbers as below: 0, 16, 32, 48 ... I need to output those numbers in hexadecimal as: 0000,0010,0020,0030,0040 ... I have tried solution such as: printf("%.4x",a); // where a is an integer but the result that I got is: 0000, 0001, 0002, 0003, 0004 ... I think I'm close there. Can anybody help as I'm ...

Why does adding to a pointer pointed to the first array member cycle through them in C?

I've just read this that by pointing a pointer to the first array member, you can cycle through by adding to the pointer. char my_array[] = "I am an array of chars"; char *my_pointer = my_array; printf("%c\n", *my_pointer); my_pointer++; printf("%c", *my_pointer); I guess this implies array members are always stored sequentially, ...

Large file parsing

I wasn't very bright and I deleted some files that I need for school. I need to parse a dump of my hard drive for the files. The file will be hundreds of gigabytes in size. Can anyone tell me a way to do this in c or python? I know that c can only handle files up to 2 gigabytes in size is there any way I can get Around this? My parsing w...

Printing a random number returns a negative number. (/dev/urandom)

I have written a source code to print random numbers within a specified limit.But it is also returning some negative numbers,is this normal?If not how do I rectify it? #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main( int argc, char* argv[]) { int fd, n; fd = open("/dev/urandom", ...

How to go about a platform independent E-Book Reader in C/C++?

Hi, I'm trying to develop an ebook reader(for mobile devices) which is platform independent. Currently my focus is epub only. As a proof of concept, we were able to make a basic epub reader for android platform, using the functionalities provided by the platform itself(using webview, Xml Parser, Unzipper etc). But now we want to make i...

Where to use volatile?

I read about volatile keyword, but I don't know in what situations I should use it. When the memory (variable) is getting updated and process is not aware of that? In what cases should drivers use volatile variables? ...

epub2pdf paginate the html format

I am working on a project which needs to convert epub to pdf. I am stuck on how to paginate the html format. Can someone give me some idea? is there any open source libs to paginate the html like the print review in most browser? ...

UNION IN C (What will be the output)

union a { int x; char a[2]; } If we assign 512 value to x and try to print a[0] and a[1] then what will be the output please explain how? ...

How to get keyboard state in Linux?

I want to check if the user pressed down the SHIFT key, when program starts. (That means, press down the SHIFT key before the program is started) It's a simple console program, nothing related to X. This maybe similar to Win32 GetKeyboardState() function. I want to know whether I can do this and how, but not any pros and cons with acc...