c

Difference between CC, gcc and g++?

What are the difference between the 3 compilers CC, gcc, g++ when compiling C and C++ code in terms of assembly code generation, available libraries, language features, etc.? ...

What does vectorization mean?

Is it a good idea to vectorize the code? What are good practices in terms of when to do it? What happens underneath? ...

How to get a FILE* stream from a file descriptor?

We can get a file descriptor from a FILE* stream by using the fileno function. Is there a function for getting a FILE* stream from the file descriptor without reopening the file? ...

error in function returning structure

#include<stdio.h> #include "amicablenumber.h" int i,j; struct amicable { int **amicablePair; int size; }; main() { int startnum = 250; int endnum = 1000; struct amicable* ami; ami = getAmicablePairs(startnum, endnum); printf("{"); for(int i = 0; i<ami->size; i++) { printf("{%d, %d}",ami->amicablePair[i][0], ami->amicab...

Recursive CreateDirectory

I found many examples of CreatingDirectory recursively, but not the one I was looking for. here is the spec Given input \\server\share\aa\bb\cc c:\aa\bb\cc USING helper API CreateDirectory (char * path) returns true, if successful else FALSE Condition: There should not be any parsing to distinguish if the path is Local or...

What's the difference between -lcurses and -lncurses when compiling C using ncurses lib?

I'm learning C and playing with the ncurses lib. I have seen references to both -lcurses and -lncurses but I have yet to find any differences (both work when compiling). Appreciate the help! ...

What is the difference between these compiler directives?

What, if anything, is the difference between these directives? #ifdef FOO #if defined FOO #if defined(FOO) I'm using the CCS compiler, but I'm interested in other C compilers as well. ...

C - Concatenate all the heads of a string

Hey fellas... OK, a recent quiz entry tasked the student with writing a method 'longhead' (char *longhead) that would return a string consisting of the concatenation of all of the heads in a given string. Example: char *string = "this"; printf("%s\n", longhead(string)); OUTPUT: tththithis I did come up with a solution, but it works ...

C programming : How does free know how much to free?

In C programming, you can pass any kind of pointer you like as an argument to free, how does it know the size of the allocated memory to free? Whenever I pass a pointer to some function, I have to also pass the size (ie an array of 10 elements needs to receive 10 as a parameter to know the size of the array), but I do not have to pass th...

How to get mac address for an interface in linux using a C Program?

i want to find the mac address using a C program in linux. how to do it? ...

OUT OF MEMORY only when virtual limit is hit?

As I know in win32 every program receives say 4GB of virtual memory. Memory manager is responsible for offloading chunks of memory from physical memory to disk. Does it imply that malloc or any other memory allocation API will throw OUT_OF_MEMORY exception only when virtual limit is hit? I mean is it possible for malloc to fail even i...

Pro*C passing a dynamic array to a PL/SQL procedure

I want to call a PL/SQL stored procedure from Pro*C which takes an array parameter (table of integer). All the documentation on the Oracle site assumed you are using a static array, or at least one defined in the same procedure as the query. I want to pass an array to a C function, that can then be sent up to the database. The problem he...

Anonymous stream in c

Can I make an anonymous stream in c? I don't want to create a new file on the file system, just have a stream that one function can fwrite to while the other can fread from it. Not c++, c. ...

What package do i need to install for using routing sockets?

i am trying code given in Unix Network Programming by Richard Stevens. but i am not able to get the code to compile. here is the source code. http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15213-f00/unpv12e/libroute/ i don't have the header file net/if_dl.h and the net/route.h header file does not include the constants and structu...

Can I do a multidimensional char array in c++?

First off, this is a "homework" question so vector libraries and string libraries are off limits. I'm trying to get to the basics of c++. My intention with this code is to make and use an array of string arrays. A list of words in other words. When I run this code I get a bunch of nonsense. If there is a better way to make a list of w...

Check double variable if it contains an integer, and not floating point

What I mean is the following: double d1 =555; double d2=55.343 I want to be able to tell that d1 is an integer while d2 is not. Is there an easy way to do it in c/c++? ...

parsing with bison

I bought Flex & Bison from O'Reilly but I'm having some trouble implementing a parser (breaking things down into tokens was no big deal). Suppose I have a huge binary string and what I need to do is add the bits together - every bit is a token: [0-1] { return NUMBER;} 1101010111111 Or for that matter a collection of tokens with no ...

Performance of math functions?

I'm working with graphing accelerometer data here, and I'm trying to correct for gravity. To do this, I get the acceleration vector in spherical coordinates, decrease the radius by 1g, and convert back to cartesian. This method is called on a timer every 0.03 seconds: //poll accleration ThreeAxisAcceleration current = self.accelerationD...

Howto get include directories (ruby.h) for Linux Ruby C extension project?

I'm using scons to build a linux C based ruby extension. What is the "right" way to get the include paths right? By "right" I mean it works out of the box on 1.9 and 1.8. I don't want to use the mkmf/Makefile solution. Thanks! Dave ...

What is the most efficient way to store and work with a floating point number with 1,000,000 significant digits in C?

I'm writing a utility to calculate π to a million digits after the decimal. On a 32- or 64-bit consumer desktop system, what is the most efficient way to store and work with such a large number accurate to the millionth digit? clarification: The language would be C. ...