c

Determine which Unit Tests to Run Based on Diffs

Does anyone know of a tool that can help determine which unit tests should be run based on the diffs from a commit? For example, assume a developer commits something that only changes one line of code. Now, assume that I have 1000 unit tests, with code coverage data for each unit test (or maybe just for each test suite). It is unlikel...

linux, write() system call returns -1 while attempting to write to file.

In the below program write() returns -1 while writing to a file. #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<stdio.h> #include<unistd.h> #include<stdlib.h> int main() { int fd_r=0,fd_w=0; int w_ret=100; fd_r = open("reader.txt", O_RDONLY); fd_w = open("writer.txt",O_C...

Game Development, the language for beginners?

I have been searching through the website looking for the best language for beginner game development. Many people say a C based language, others suggest Python. Normally I would just pick one, but this is my dilemma. I am not sure if this is correct, but I read from programmers on here that C is much faster at 3d render, whereas Python...

What is the need of randomizing memory addresses for loading libraries?

ldd displays the memory addresses where the shared libraries are linked at runtime $ cat one.c #include<stdio.h> int main() { printf ("%d", 45); } $ gcc one.c -o one -O3 $ ldd one linux-gate.so.1 => (0x00331000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00bc2000) /lib/ld-linux.so.2 (0x006dc000) $ From this answer...

getline check if line is whitespace

Is there an easy way to check if a line is empty. So i want to check if it contains any white space such as \r\n\t and spaces. Thanks ...

Use of [] in fscanf()

I've a text file with following contents: "abc","def","ghi" The following works to read the file contents properly: int main() { char name[1024] = {0}; FILE *file = fopen("file.txt", "r"); while(1) { if (fscanf(file, " %[\",]s ", name) == EOF) break; if (fscanf(file, " %[a-zA-Z]s ", name) ...

Convert integer to string without access to libraries [c]

I recently read a sample job interview question: Write a function to convert an integer to a string. Assume you do not have access to library functions i.e., itoa(), etc... How would you go about this? ...

Implement generic swap macro in C

Possible Duplicate: is there an equivalent of std::swap() in c Hi folks, I was attempting a problem to write a generic swap macro in C and my macro looks like this: #define swap(x,y) { x = x + y; y = x - y; x = x - y; } It works fine for integers and floats but I am unsure if there is any catch in it. What if by generic ma...

Fast 2D convolution for DSP

I want to implement some image-processing algorithms which are intended to run on a beagleboard. These algorithms use convolutions extensively. I'm trying to find a good C implementation for 2D convolution (probably using the Fast Fourier Transform). I also want the algorithm to be able to run on the beagleboard's DSP, because I've heard...

Way to pass argv[] to CreateProcess()

My C Win32 application should allow passing a full command line for another program to start, e.g. myapp.exe /foo /bar "C:\Program Files\Some\App.exe" arg1 "arg 2" myapp.exe may look something like int main(int argc, char**argv) { int i; for (i=1; i<argc; ++i) { if (!strcmp(argv[i], "/foo") { // handle /foo } e...

C++ SQL Queries/SQL Wrapped for C++?

Just more a general question I can't seem to find a definite answer on. But what is a good SQL wrapper for C++ that allows me to call queries? I'm used to Oracle, but i've used MYSQL before aswell. And how would you call something such as an insert statement (for example) in one? ...

How to tell gcc to instrument the code with calls to my own function each _line_ of code?

For example, there is the source: void my_special_debugging_function(const char* function_name, const char* file_name, int line_number); void func1() { func3(); func4(); } void foo() { func1(); if(qqq) { func2(); }; func3(); func4(); for(...) { func5(); } } It should compile as: v...

OpenCV show both incoming video and modified video in separate windows

Hi. This should be easy. I have a video stream coming in from my webcam. I'm just playing with image transformation etc. I'd like to be able to view the original images (video input) in one window and the transformed video in another. Problem is, as soon as I start capturing video instead of just single images, the original video wi...

Is it possible to store a FILE * in a user defined struct?

Hi all, first post here so be nice ;) Is it possible to store a FILE * in a struct, i see no reason why not but the following code wont compile, i can't seem to store a reference to file pointer either. typedef struct fileType { FILE * file; char fileName[MAX_FILENAME_LEN]; unsigned linesRead; unsigned nextBufLine; ...

Colons after variable name on C code.

Possible Duplicate: What does 'unsigned temp:3' means This is C code sample of a reference page. signed int _exponent:8; What's the meaning of the colon before '8' and '8' itself? ...

How to run a Simple C Program in Eclipse IDE

I've downloaded Eclipse C/C++ IDE . I need to run a simple c program in this(To print welcome). While trying to run the program its popping up an error message like "Launch failed: Binary not found" . Need i install any compiler package. ? Please help me to do this. ...

The best way I know to write readable regex in C and C++

The question is: http://stackoverflow.com/questions/3978351/how-to-avoid-backslash-escape-when-writing-regular-expression-in-c-c Stackoverflow does not allow to answer my own question. So I post it as a faked "question" When I reading [C: A reference manual] Chapter 3: Prepressors. An idea emerges: #define STR(a) #a #define R(var, r...

IDE for C Programming?

Can any one suggest me a Best IDE for C programming ( With auto completion feature)? ...

What is bad file descriptor in c?

This is my code of function that wants to read file: int sendByByte(int filed,int sockfd,int filesize) { int i=0; int sent=0; char buf[BUFSIZE]; while(i<filesize) { printf("fd is : %d\n",filed); printf("i: %d\n",i); int byte_read=read(filed,buf,BUFSIZE); if(byte_read == -1) { printf("MOSHKEL dar read\n"); return -1;...

man 2 stat - how to figure out if a file is a link

I have the below code only a part of it is shown here and I am checking if a the type of file. struct stat *buf /* just to show the type buf is*/ switch (buf.st_mode & S_IFMT) { case S_IFBLK: printf(" block device\n"); break; case S_IFCHR: printf(" character device\n"); break; case S_IFDIR:...