c

return from 1 point in function

Possible Duplicate: Should a function have only one return statement? Hello, gcc 4.4.4 c89 Is it good programming practice to return from 1 point in a function. I have written a function below. However, I am returning from 2 possible points. Is this good style? static int init_data(struct timeout_data_t *timeout_data) { ...

converting a C hashing function to PHP : ezmlm_hash

Hi, I'm trying to upgrade from PHP 5.2.x to 5.3.2 on my server. Problem is, I relying on the broken implementation of PHP's ezmlm_hash() (the bug is outlined here: http://bugs.php.net/bug.php?id=47969). My first thought was to rewrite the broken version of the native PHP function (which is written in C) myself in PHP and use that in my ...

Is there any free C/C++ code to flowchart generator tool available on the net?

Is there any free C/C++ code to flowchart generator tool available on the net for download? ...

Question about The modified-GNU algorithm

I read the article Optimizing Memcpy improves speed, I have a question about the modified-GNU algorithm, I get an error running the code the src & 0xFFFFFFFC , src is a void pointer, can it be a left operand for ‘&’ ? Did I miss anything here? Thanks Error 1 error C2296: '&' : illegal, left operand has type 'const void *’ vo...

Cyclical Linked List Algorithm

I have been asked recently in a job interview to develop an algorithm that can determine whether a linked list is cyclical. As it's a linked list, we don't know its size. It's a doubly-linked list with each node having 'next' and 'previous' pointers. A node can be connected to any other node or it can be connected to itself. The only s...

can not count array elements after passing as argument

I am having issues counting the array elements after passing it into an arguement void GXDX::LoadMesh(GXVector vertices[], UINT indices[] = NULL) { D3D10_BUFFER_DESC bufferDesc; UINT numVerts = sizeof(vertices)/sizeof(GXVector); bufferDesc.Usage = D3D10_USAGE_DEFAULT; bufferDesc.ByteWidth = sizeof(GXVector) * numVerts;...

Line wrapping in GtkCheckButton or GtkRadioButton labels

Is there any way to get the label of a GtkCheckButton or GtkRadioButton to wrap when its parent container is resized small enough so the label won't fit on one line? ...

copy a file and change its permissions in Linux with C

I copy a file by opening the source in read-only mode and the destination in write-only mode. It's simple and it works. The problem is that sometimes I am copying a file that sits on an NFS drive, or other network drives and when in these cases the permissions get all screwed and SELinux complains. I then go and manually set the permiss...

What is the correct way to perform alpha blending? (C)

Hi, I'm writing a very simple graphics library, and I'm trying to figure out how to do alpha blending. I tried it a few times, but my results were less than satisfactory. According to Wikipedia, I should do: Value = (1-alpha)*Value0 + alpha*value1 This, however is not working at all. Maybe I'm doing something wrong? The code I've inc...

QTMovie backed by a Movie works initially, but not in another method

What follows is an initializer method. It creates a Movie structure from a file, with an eye to extracting the raw pixels for processing, as per Apple QA1443. This is then wrapped in a QTMovie – sourceMovie = [QTMovie movieWithQuickTimeMovie: ...] – for convenience. After initializing such an object, the second method is called, and we ...

2d array addition

This program adds two matrices but it's giving too many errors and I can't solve them. Errors: ARRAY BOUNDS MISSING and EXPRESSION SYNTAX Any ideas? #include<stdio.h> #include<conio.h> #define ROW=3 #define COL=3 int result[][COL]; void input(int arr[][COL]); void add(int mat1[][COL],mat2[][COL]); void print(int result[][...

Why compilers creates one variable "twice"?

Hi, I know this is more "heavy" question, but I think its interesting too. It was part of my previous questions about compiler functions, but back than I explained it very badly, and many answered just my first question, so ther it is: So, if my knowledge is correct, modern Windows systems use paging as a way to switch tasks and secure ...

Is a strlen call in snprintf causing this segfault?

I have a void *, call if data which length I know, but is not terminated. I make a call like this snprintf(line, sizeof(line), "%*s", n, (const char*)data) where n is the known length. Almost always this works, but occasionally it results in a segfault. Whenever the segfault occurs, the back trace says the problem is inside strlen. ...

Techniques to prevent overdraw (OpenGL)

I'm drawing lots of semi transparent polygons. My scene is 2D and uses 2f verticies. I can't use the depth buffer since it wont help because of alpha blending. What are some other techniques to reduce overdraw since this is what is crippling my application, not polygon counts since I use VBO's. Thanks ...

Overhead of times() system call - relative to file operations

What is the relative overhead of calling times() versus file operations like reading a line fread(). I realize this likely differs from OS to OS and depends on how long the line is, where the file is located, if it's really a pipe that's blocked (it's not), etc. Most likely the file is not local but is on a mounted NFS drive somewhere ...

Zooming into the mouse position with a translation?

To zoom into the mouse position I was using: glTranslatef(current.ScalePoint.x,current.ScalePoint.y,0); glScalef(current.ScaleFactor,current.ScaleFactor,current.ScaleFactor); glTranslatef(-current.ScalePoint.x,-current.ScalePoint.y,0); so basically I translate to the new origin (the mouse position) then scale by the current sc...

Getting the points from wglUseFontOutlines?

I'm making a vector application for Windows. Right now i'm using wglUseFontOutlines to generate display lists which wrks well, except I would like to be able to let the user remodel the font. I would also like to use VBO's instead of DL's for this. Does Microsoft provide a way to get the points for this, or atleast the outlines, I could ...

Problem with structures, where to put them and how to reference them in headers?

OK, I'm in a dilemma right now, and neither my knowledge of C (which isn't the biggest one anyways) nor the almighty Google seem to be able to help me with this: I have some structures for a game prototype: Map (Uhhm... the Map..) Chara (A base for Enemies the Players) Player (The Player) Now the problem is: Map needs a refere...

How to get the workaround for GCC warning, "the address of XXX will never be NULL"?

Hi, all. I'm working on C program. There is a function which takes two pointer argument and does some complex works. Let's say it as 'cmp'. cmp() is never complex for the illustrative reason. int cmp(struct foo *a, struct foo *b) { return (a->bar == b->bar); } I'd like to make a NULL-check macro, like this: #define SAFE_CMP(a,b...

sorting strings in a file

hello guys! I need a solution for sorting of unix pwd file using C++ based on the last name. The format of the file is username, password, uid, gid, name, homedir, shell. All are seperated by colon delimiters. The name field contains first name follwed by last name both seperated by space I am able to sort the values using map and i am...