c

Implementation of string literal concatenation in C and C++

AFAIK, this question applies equally to C and C++ Step 6 of the "translation phases" specified in the C standard (5.1.1.2 in the draft C99 standard) states that adjacent string literals have to be concatenated into a single literal. I.e. printf("helloworld.c" ": %d: Hello " "world\n", 10); Is equivalent (syntactically) to: ...

question about swap bits

i have question on this topic i think that answer is incorrect look http://stackoverflow.com/questions/1192487/swap-bits-in-a-number-in-c 1110 1011 it is equal 235 but i get 3051 why? ...

Finding Bit Positions in an unsigned 32-bit integer

I think I might have been asleep in my CS class when they talked about Bit Positions, so I am hoping someone can lend a hand. I have a unsigned 32-bit integer (Lets use the value: 28) According to some documentation I am going over, the value of the integer contains flags specifying various things. Bit positions within the flag are nu...

Pointer Naming Preferences

Possible Duplicate: Whats your preferred pointer declaration style, and why? Just curious: What's you standard method when declaring pointers? Why? SomeClass *instance; OR SomeClass* instance; I prefer the second method as it keeps the entire type together (it's a 'SomeClass pointer'). But I know many prefer the first an...

C code compiles as C++, but not as C

Possible Duplicate: Convert some code from C++ to C I've got some code that appears to be straight C. When I tell the compiler (I'm using Visual Studio 2008 Express) to compile it as c++, it compiles and links fine. When I try to compile it as C, though, it throws this error: 1>InpoutTest.obj : error LNK2019: unresolved exter...

Reading C data file in F90

Hi, I am not an expert in programming but have some experience. It is more than a week that I am trying to read a data file from C into a Fortran program. C program saves a matrix in a bin format data file as follow: FILE * amatFile; amatFile = fopen("A.dat","wb"); for(krowa=0;krowa<N2;krowa++){ fwrite(amat[krowa], sizeof(float), ...

Need to ramp on software design fast (8 year ASIC/FPGA system designer)

Hi, I hope you guys can help me out. I'm a 8 year ASIC/FPGA designer who's worked mainly on a system level. I'm quite familiar with C and Java but more of a test code role rather then production firmware/driver code. I've been recently asked to be a Product Lead with the Software Group working on derivative products. What that means is...

splint failing on code that includes complex.h

I'm trying to run splint on a C source that includes complex.h from the standard C library to support complex arithmetic. Unfortunately, splint fails with the following error. Splint 3.1.2 --- 03 May 2009 /usr/include/bits/cmathcalls.h:54:31: Parse Error: Non-function declaration: _Complex : extern double. (For help on...

malloc in C, but use multi-dimensional array syntax

Is there any way to malloc a large array, but refer to it with 2D syntax? I want something like: int *memory = (int *)malloc(sizeof(int)*400*200); int MAGICVAR = ...; MAGICVAR[20][10] = 3; //sets the (200*20 + 10)th element UPDATE: This was important to mention: I just want to have one contiguous block of memory. I just don't want to...

Why do I get a segfault in C from declaring a large array on the stack?

I get a segfault from this line of code: int fatblob[1820][286][5]; Why is that? ...

Getting an int array in JNI

I've seen some questions on how to properly pass a C array into Java using JNI, but I have the reverse problem: How do I properly call an int array getter method in C using JNI. Specifically, I want to pass a BufferedImage instance into C and call the "public int[] getRGB()" method on this BufferedImage instance. My understanding is th...

When main is defined without parameters, will argc and argv still be present on the stack?

Consider the very simple: int main(void) { return 0; } I compiled it (with mingw32-gcc) and executed it as main.exe foo bar. Now, I had expected some sort of crash or error caused by a main function explicitly declared as being bereft of life parameters. The lack of errors led to this question, which is really four questions. W...

2D game development basics

Hi, I would like to write some simple Mario-like game from scratch using language C. But honestly I have no idea how to do so, and I can´t find any good tutorial for this, which is for free. But to the actuall question, I have only written WinAPI programs so far, so all event handling and user input was handled by OS, with minimum work,...

simulate a Three-State process model (ready, running and blocked) and a simple process control block structure

program will read input and directives from a file. The input describes a time sequence of events that occur. These are the full set of events you will simulate: cpu - The processor runs for 1 time step the currently running process new - A new process is created done - The currently running process has finished wait X - T...

Problem with type-casting array of strings in C

I am trying to read a large list of English words from a text file to array of strings. The number of words is 2016415, and maximum length of a word is 69 characters. If I define array like "char data[2016415][70]; " then I get stack overflow when I run the program. So I am trying to use calloc() instead, however I can't understand how...

How to power down the computer from a freestanding environment?

I'm making a protected-mode OS based on Intel's x86 architecture, and was looking for some information on how to power off the computer via assembly code, or something like that. Could you help me with this problem? ...

Does this cause a memory leak?

I create my VBO like this: glGenBuffersARB(1,&polyvbo); glBindBufferARB(GL_ARRAY_BUFFER_ARB,polyvbo); glBufferDataARB(GL_ARRAY_BUFFER_ARB,sizeof(GLfloat) * tempvct.size(),&tempvct[0],GL_DYNAMIC_COPY); Then to update it I just do the same thing: glBindBufferARB(GL_ARRAY_BUFFER_ARB,polyvbo); glBufferDataARB(GL_ARRAY_BU...

C, function pointer with arguments preset

Is something like this possible in C? #include <stdio.h> void print_str(char *str) { printf(str); } int main() { void (*f_ptr)() = print_str,"hello world"; f_ptr(); } //see "hello world" on stdout In short, I'd like to have a function pointer that "stores" the arguments. The point is that the function po...

Should Direct3D be used over OpenGL in Windows?

Since Microsoft is generally a bit bias toward Direct3D, would a scene using VBO's in Direct3D be faster than the same scene using VBO's in OpenGL, or would it be the same since it's up to the Graphics Card driver? Thanks ...

Objective C version of explode()?

If I want to explode a string by parts in PHP into an array, I have the nifty explode() function where I just do the following $mystring = "HI:THERE:HOW"; $stringarray = explode(":", $mystring); And I get $stringarray = ( [0] = "HI" [1] = "THERE" [2] = "HOW" ); Is there a similar function in Objective C that explodes a string...