Hi,
To be on the same page, let's assume sizeof(int)=4 and sizeof(long)=8.
Given an array of integers, what would be an efficient method to logically bitshift the array to either the left or right?
I am contemplating an auxiliary variable such as a long, that will compute the bitshift for the first pair of elements (index 0 and 1) and...
I'm not familiar with bitwise operators, but I have seem them used to store simple settings before.
I need to pass several on/off options to a function, and I'd like to use a single integer for this. How can I go about setting and reading these options?
...
Is there a quick way to convert a float value to a byte wise (hex) representation in a QByteArray?
Have done similar with memcpy() before using arrays, but this doesn't seem to work too well with QByteArray.
For example:
memcpy(&byteArrayData,&floatData,sizeof(float));
Can go the other way just fine using:
float *value= (float *)by...
In C following this article (http://blogs.msdn.com/oldnewthing/archive/2006/12/21/1340571.aspx), we have succesfully been able to grab the file version information out of windows files however there are some files that seem to have a different mechanism for storing the version information that is not addressed in the article and was wond...
I was wondering why in some source code there are these macros like FAR and PASCAL. What do they mean and do?
Thanks
...
Found some info on porting packages from python 2 to 3 using distribute setuptools in below link.
http://packages.python.org/distribute/python3.html
I have a C api which could be build using python 2.x, but i need to build it in python 3.x.
Can it be done using distribute.
Do anyone have idea on this?
...
Hi,
I'm currently migrating some of my code from Cocoa (Apple's Objective-C API) to C, in order to make it available for other operating systems, such as GNU/Linux.
In Cocoa, there were many great things like creating NSTimeZone objects from their string descriptors using timeZoneWithAbbreviation:. This allowed me to use values like "E...
In the code below I have a function int GetTempString(char Query[]);
calling it in main works fine.
However, when calling the function from a fork the fork hangs (stops running, no errors, no output) before this line: pch = strtok (Query," ,"); the printf shows that the pointer to pch is null. Again this only happens when the fork is ex...
I am using fcntl locks in C on linux and have a dilemma of trying to delete a file that may possibly be locked from other processes that also check for the fcntl locking mechanism. What would be the preferred way of handling this file which must be deleted, (Should I simply delete the file w/o regard of other processes that may have read...
#define IPTOSBUFFERS 12
char *iptos(u_long in)
{
static char output[IPTOSBUFFERS][3*4+3+1];
static short which;
u_char *p;
p = (u_char *)∈
which = (which + 1 == IPTOSBUFFERS ? 0 : which + 1);
_snprintf_s(output[which], sizeof(output[which]), sizeof(output[which]),"%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
...
The definition can be seen here.
The candidate answer may be tcp and dst port 80,but can tcp and dst port 80 guarantee it's HTTP traffic and includes all HTTP traffic?
It seems not,because some site can be visited by specifying a different port other than 80 this way:
http://domain.name:8080
So my question is: what's the exact BPF f...
I have a C shell script that calls two
C programs - one after the another
with some file handling before,
in-between and afterwards.
Now, as such I have three different files - one C shell script and 2 .c files.
I need to give this script to other users. The problem is that I have to distribute three files - which the users m...
Hi,
I was thinking about a typical problem that is very JIT-able, but hard to approach with raw C. The scenario is setting up a series of function pointers that are going to be "composed" (as in maths function composition) once at runtime and then called lots and lots of times.
Doing it the obvious way involves many virtual calls, that...
How do I pass a pointer value to an array of the struct;
For example, on a txt I have this:
John Doe;[email protected];214425532;
My code:
typedef struct Person{
char name[100];
char email[100];
int phone;
}PERSON;
int main(){
PERSON persons[100];
FILE *fp;
char *ap_name;
char *ap_email;
char *ap_phone...
What is the most efficient for speed algorithm to solve the following problem?
Given 6 arrays, D1,D2,D3,D4,D5 and D6 each containing 6 numbers like:
D1[0] = number D2[0] = number ...... D6[0] = number
D1[1] = another number D2[1] = another number ....
..... .... ...
Is there a way to map floats to ints or unsigned ints so that with the exception of NaN, order is preserved?
So if a and b are floats, and F is the mapping function,
a < b implies F(a) < F(b)
and
a == b implies F(a) == F(b)
...
I'm seeing what I think is strange behaviour from object files output by the Microsoft Visual Studio 2003 tools. The file utility tells me:
asmfile.obj: 80386 COFF executable not stripped - version 30821
For objects created by the assembler, but for objects coming from C files, I get just:
cfile.obj: data
Using Microsoft's dumpbin...
Hello to everybody..and greetings from Greece
I have a C program for an exercise and it has a strange issue
The program runs just fine on VS 2005 but it crashes on DEV-C++ and the problem that the problem is that the exercise is always evaluated against DEV-C++
The program is about inserting nodes to a BST and this is where the problem ...
How can i multiply and divide with only using bit shifting and adding?
...
Hi there,
Im trying to ask the user to enter the number of columns and rows they want in a matrix, and then enter the values in the matrix...Im going to let them insert numbers one row at a time.
How can I create such function ?
#include<stdio.h>
main(){
int mat[10][10],i,j;
for(i=0;i<2;i++)
for(j=0;j<2;j++){
scanf("%d",&mat[i][...