c

Is there a portable C compiler for windows?

I want to carry one in my flash drive and run it. Thanks ...

How best do I get to use OpenMP on Mac OS X 10.5 and Ubuntu 10.4?

I'm looking at an open-source library (DDS, a double-dummy bridge solver) which in its latest release (2.1.1) adds some very useful multi-tasking functionality requiring either a Windows system or OpenMP (indeed, that latest version won't even compile at all on a non-Windows system without full OpenMP support!-). Ubuntu 10.4 has a packa...

Productivity tools for C & C++ software development

In this day and age of advanced IDEs with plethora of functions, what tools you wish you had in your software development tool box to accelerate your day to day C & C++ software development? Please list the tools you wish you had but did not have time to code for yourself. For instance, it would be nice to have a tool to check if a parti...

Mixing assembler code with c/c++

Why is assembly language code often needed along with C/C++ ? What can't be done in C/C++, which is possible when assembly language code is mixed? I have some source code of some 3D computer games. There are a lot of assembler code in use. ...

How do flags work in c?

Ok I want to add some sort of flag like variable to one of my classes and had some questions about going about doing it. After looking at some source that uses it I noticed some stuff like this. TEXTUREFLAGS_POINTSAMPLE = 0x00000001, TEXTUREFLAGS_TRILINEAR = 0x00000010, Does the way this work is by combining all the flags into one int...

How to read available input without blocking on Windows

Hello. On Linux, I can read available input without blocking the process: fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK ) char buf[n]; int r = fread(buf, 1, n, stdin); if (r == 0){ printf("nothing\n"); } else { printf("read: "); fwrite(buf, 1, r, stdout); printf("\n"); } The input origin ca...

Trapping the mouse?

I'm using GLUT and developing a FPS game. I need a way to trap the mouse so that the camera continues to move because right now when the mouse position exceeds the monitor limit, there is no way to calculate change in X or change in Y. How can I 'trap' the mouse with GLUT? Thanks ...

Linked List in C (memory problems)

I'm creating a simple linked list in C in order to get used to some memory management. I've defined a node structure that holds a char* key, char* value and a node* next. void newnode(node *n, int x, int y) { n->key = malloc(x*sizeof(char)); n->value = malloc(y*sizeof(char)); } //This how i create a new node given a key and v...

Numerical Error in simple CUDA code

I just started experimenting cuda with the following cude #include "macro.hpp" #include <algorithm> #include <iostream> #include <cstdlib> //#define double float //#define double int int RandomNumber(){return static_cast<double>(rand() % 1000);} __global__ void sum3(double const* a, double const* b, double c...

Are there tools that help organizing #includes?

Are there any tools that help organizing the #includes that belong at the top of a .c or .h file? I was just wondering because I am reorganizing my code, moving various small function definitions/declarations from one long file into different smaller files. Now each of the smaller files needs a subset of the #includes that were at the ...

Does making the iterator a pointer speed up a C loop?

I ran the following: #include <stdio.h> typedef unsigned short boolean; #define false 0 #define true (!false) int main() { int STATUS = 0; int i = 0; boolean ret = true; for(i = 0; i < 99999; i++) { ret = ret && printf("Hello, World."); } if(!ret) { STATUS = -1; } return STATUS; ...

why for(;;) instead of while(1)?

Possible Duplicate: Is for(;;) faster than while (TRUE)? If not, why do people use it? Why use the ugly for(;;) syntax instead of the slightly better looking while(true) loop? ...

| operator versus || operator

Simple question but what does the | operator do as opposed to the || (or) operator? ...

How to organize my c code

I have large main file contains about 7,000 lines of C code. If I want to make this code modular and separate the code from this file. what is the main criteria for separating the functions out of the file and functions that should stay in the file. ...

Why do two floating point multiplies give a different answer than one?

I recently ran into an issue where I wasn't getting the numerical result I expected. I tracked it down to the problem that is illustrated by the following example: #include <stdio.h> int main() { double sample = .5; int a = (int)(sample * (1 << 31)); int b = (int)(sample * (1 << 23) * (1 << 8)); printf("a = %#08x, b = %#08x\n",...

Valgrind / Memory Errors

I'm receiving the following errors repeatedly throughout my code when I use valgrind. I'm not quite sure what these mean and I can't identify the uninitialized values. ==16795== Conditional jump or move depends on uninitialised value(s) ==16795== at 0x4A06E8A: strcmp (mc_replace_strmem.c:412) ==16795== by 0x4009C7: dictionary_add...

Opening a file in 'a+ 'mode

If a file is opened using the following command: FILE *f1=fopen("test.dat","a+"); The man page reads: a+ Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but...

Quine Confusion.What actually does quine prints?

Does a quine print the ACTUAL code of the program i.e not obfuscated or does it print the obfuscated program? ...

Reference to an address?

#include<stdio.h> int main(void) { int arr[3]={1,2,3}; return 0; } Now what will *(&arr) give me and why? I want a detailed explanation. Don't just tell me how * and & cancel out :P I want to know how the compiler interprets this expression to give the desired result. ...

how to make the execution time less(ie. a faster code) for this problem

this question is from Codechef.com [if anyone is still solving this question dont look further into the post before trying yourself] and although it runs right, but i need to make it a lot faster.i am a beginner in c,c++.(i know stuff upto arrays,strings and pointers but not file handling etc).So is there a way to make this program run a...