very basic c question
as we use pointers in the argument list of functions like void f(int *); this means that this function will receive a pointer to an integer but what does this means void f(int ***); and void f(int **=0) ...
as we use pointers in the argument list of functions like void f(int *); this means that this function will receive a pointer to an integer but what does this means void f(int ***); and void f(int **=0) ...
I compile this bit of code on Snow Leopard and linux and I get different results. On Snow leopard, the first call of omp_get_max_threads returns 2, which is my number of cores, while the second returns 1. On linux, both calls return 4, which is my number of cores. I think Linux has the correct behavior, am I right? Are both correct a...
Consider two applications: one (num. 1) that invokes malloc() many times, and the other (num. 2) that invokes malloc() few times. Both applications allocate the same amount of memory (assume 100MB). For which application the next malloc() call will be faster, #1 or #2? In other words: Does malloc() have an index of allocated locations in...
Making my Asteroids clone (in C) I've rather fallen in love with vector-based entities, but I've simply coded them in as x,y-point arrays. That's been fine for something like Asteroids, but what should I do if I want to make more complex 2D models? I note that there is an awful lot of 3D modelling software out there, as well as ample tu...
I don't see why this error is coming up. Maybe someone else sees it. Here's the error. actor_plazma.c:92: error: incompatible types when initializing type ‘int (*)(struct VisObject *)’ using type ‘float’ actor_plazma.c:92: error: incompatible types when initializing type ‘void *’ using type ‘float’ make: *** [actor_plazma.lo] Error 1 ...
Hey guys, I'm relatively new to C, so forgive me if this is a stupid question, but how would I go about checking if a FILE is a directory? I have if (file == NULL) { fprintf(stderr, "%s: No such file\n", argv[1]); return 1; } and that checks if the node exists at all, but I want to know if it's a dir or a file. I've d...
I have a program. I want it to be able to mmap a particular region of memory over different runs. I have the source code of the program. C/C++ I control how the program is compiled. gcc I control how the program is linked. gcc I control how the program is run (Linux). I just want to have this particular region of memory, say 0xabcdab...
is there any way to create a daemon in unix that would monitor my battery level and notify me after the crtical level. and is there any way to identify a node that is joining and leaving a network using c ...
I have a packet capture code that writes http payload into a file. Now i want to extract the URL information from these dumps. For each packet , the payload begins like this. GET /intl/en_com/images/logo_plain.png HTTP/1.1..Host: www.google.co.in..User-Agent: Mozilla/5.0 I would like to extract : the string between "GET" an...
I am linking an application with mysqlclient library on 64-bit CentOS 5.4 and get a linkage error (cannot find -lmysqlclient). The library is in /usr/lib64/mysql/: una@localhost$ ll /usr/lib64/mysql/ total 9072 ... lrwxrwxrwx 1 root root 26 Jan 3 15:54 libmysqlclient_r.so -> libmysqlclient_r.so.15.0.0 lrwxrwxrwx 1 root root ...
I have a memory address of the start of a number of structs, but need to eliminate some from my output. I think the memory space would look something like +------------------+------------------+------------------+ | struct | struct | struct | | linux_dirent64{ | linux_dirent64{ | linux_dirent64{ | | ...
I have a c console app which converts a c file to a html file, the c file location is passed to the program as a command line argument.(the app is for the windows platform) What I would like to do is have a python gui app to allow the user to select a file and pass the location of the file to the c app for processing. I already know ho...
Hello everyone, I want to transfer binary files to remote server. I am using SUN/ONC RPC (rpcgen on Linux) for my code. I am using C. I have written code for server and client and it works for text files, but when I try to transfer binary files it says the file is corrupted after transfer. I am storing data chunks in character array o...
Just out of interest , is it possible to call a C module from a java module ? If so , how to do that ? ...
I am trying to learn C. Reading through some code I came across a line like this: __inline__ void () ... What does the __inline__ mean? And how does putting that word in front of a function make it different? ...
I am building a server-client program with c and having some problen wtih sendina a whole file with send() and recv() function. I need to send the whole file with these but all these functions can do is send a string. The main problem is with sending the exe or other binary formet data. Should I use htons or htonl func? I dunno how to u...
Hi, I know in C++, you're able to peek at the next character by using: in.peek();. How would I go about this when trying to "peek" at the next character of a file in C? ...
Hi, I need to compare an enum as a whole to one string, so the whole contents of the enum is checked. Wanted something like: NSString *colString = [[NSString aloc] initWithString:@"threeSilver"]; typedef enum { oneGreen, twoBlue, threeSilver }numbersAndColours; if (colString == numbersAndColours) { //Do cool stuff } But obviousl...
The title says everything. I am talking about C/C++ specifically, because both consider this as "implementation issue". I think, defining a standard interface can ease building a module system on top of it, and many other good things. What could C/C++ "lose" if they defined a standard ABI? ...
How can I check if a double x is evenly divisible by another double y in C? With integers I would just use modulo, but what would be the correct/best way to do it with doubles? I know floating point numbers carry with them imprecision, but I'm getting the double from standard input. Maybe I should not scan it as a double straight away b...