c

Is this an invalid use of restrict pointers?

Suppose I have large array which I calculate an index into and pass to a second function. As a simple example, something like: void foo(float* array, float c, unsigned int n) { for (unsigned int i = 0; i < n; ++i) array[i] *= c; } void bar(float* restrict array, float* restrict array2, unsigned int m, unsigned int n) { ...

integer range in c

why integer has a range between 0 and 32768? ...

Referencing a type in a struct before it is defined

I'm looking for a good way to do something like this: typedef struct user { unsigned long id; //userList defined below userList friends; } typedef struct { //userList contains users user * list; int count; } userList; Is there a legal way to do this or something similar? ...

function to traverse on a 5*5 grid in lowest no. of turns in C

I am actually doing coding for a grid solver in C. Now i have defined a function called void get_target(void){} which has to set the target_x and target_y coordinates to a value on 5*5 coordinate system. I want to traverse the grid in least possible time covering all points with minimum number of turns( only 90deg turns, 180 deg turns...

Zombie processes......

I'v some questions about zombie processes what the benefits from zombie process concept? know that the kernel keeps (PID,termination status, resource usage information) for zombie process what's the meaning of "resource usage information" how zombie's PPID() = 1 and it still zombie , (init reaps Zombies because it wait() by default) ...

checking when all data is sent using non-blocking open

If I open a a file as os.open( '/dev/ttyS2', O_RDWR | O_NDELAY ), is there any way that I can check when my 'write()' commands have finished? Or, can I open a file for non-blocking read but blocking write? ...

Using C Preprocessor to Determine Compilation Environment

I am building an application that consists of both a windows driver written in C and a user mode executable in c++. They both use a shared header file to define several macros, constants, enums, etc. In the c++ version, I want to include everything within a namespace, which a feature not supported by the c compiler. Is there certain v...

What type of Sorting algorithm is this?

If this is Bubble sort then what is this? Do you see the placement of Swap()? ...

OPENSSL and private key

Hello guys and gals! Openssl is a great security library and I use it from time to time. When I generate RSA keys I have RSA object with private and public key data. OK. Fine. I'm happy with that. I can print private key to the printer. And here come's the question. Is it possible to create a valid RSA object only from the entered pri...

Get console handle

Hi, How do I get the console handle of an external application? I have a program running as a console. I have a 2nd program that will call GetConsoleScreenBufferInfo, but for that I need the console handle of the first program. Is it possible that given the HWND of the 1st program I can get its console handle? ...

In Linux using C++ and GCC, is it possible to convert the virtual address to a physical address?

Under Linux, C++, and GCC, can I get a physical address for a given virtual address? I know I won't be able to manipulate the physical address as a physical address. ...

Passing an C# array of structs with array of double member to C DLL by reference

We have the following code marshalling between c# and c dll. However, when print the value within the C dll function, the values associated with the double array properties are all 0.0000000. I have put some in line comments for the code having problems. Did we miss any thing to configure the marshalling behaviour? using System; using...

How do hidden structures work?

I notice in several API's, that you may create a struct which is used internally and has nothing. ex: ALLEGRO_BITMAP *bmp; ... bmp->(intellesense shows nothing) how do these types of structures work? are they simply handled like this internally? REAL_ALLEGRO_BITMAP *realbmp = (REAL_ALLEGRO_BITMAP*)bmp; or is there a cleaner soluti...

C - Copy string into a linked list variable

#define STRLEN 65 /*Create linked list */ struct node { char str[STRLEN]; struct node *next; }; newInput = malloc(sizeof(struct node)); strcpy(newStr, newInput->str); I left the other parts of the code, but it doesnt seem to be copying the string into newInput->str. The string accepted is only 64 bytes. It's just blank when...

C Realloc error - "Assertion `ptr == alloc_last_block' failed!"

I'm writing a function in C that takes in a linked list and a predicate and returns an array containing all values of the linked list satisfying this condition. Here's the function: void **get_all_that(list_t *l, int (*pred)(const void *)) { void **vals = NULL; int i = 0; // Number of matches found const size_t vps = sizeof(...

What systems out there use non-uniform pointer representation?

Possible Duplicate: Are there are any platforms where pointers to different types have different sizes? I have read in several places that pointers of different types may have different representations in standard-conforming C implementations. This is one thing that makes it necessary to cast pointer arguments to printf, e.g....

Program to read a code and count the number of lines in it,do not include comments and blank lines in count

I am trying to create a program which, given an input file, returns the count of all the lines of code in the input file, excluding blank lines and comment lines. I have written the following code, however I need help with how to exclude lines containing comments and blank lines. #include<stdio.h> int main() { int count; char ch...

C, first member of struct

I have yet another newbie C question: Why does the first member of a struct return an adress not similar to the structs own pointer-adress when not initialized? Example: struct Metadata { int message_ID; //other members... //... }; struct Metadata* baseMetadataPtr = (struct Metadata*) malloc(sizeof(struct Metadata)*100); ...

Can sizeof(int) ever be 1 on a hosted implementation?

My view is that a C implementation cannot satisfy the specification of certain stdio functions (particularly fputc/fgetc) if sizeof(int)==1, since the int needs to be able to hold any possible value of unsigned char or EOF (-1). Is this reasoning correct? (Obviously sizeof(int) cannot be 1 if CHAR_BIT is 8, due to the minimum required r...

Internet Explorer Address Space

Though i'm currently interested in internet explorer address space i wouldn't mind a general answer. The question is how can i calculate the address space ( and by address space a mean the minimum and maximum address in memory -correct me if i'm wrong- ) of a windows process. Actually is this space fixed or varied ? Also do i get to kno...