c

_popen in windows with both stdout and stdin

How to popen with both stdin and stdout in windows in c? ...

How to get data from a variable parameter list?

I have following function with only a variable parameter list (Without supporting/fixed argument). Is it possible to get values passed to this function? I am using ANSI format. Foo( ... ) { } Adding some more points for clarity. In my special case, the number of arguments and their types are stored in a .xml file as configurations wh...

C - determine if a number is prime

I am trying to come up with a method that takes an integer and returns a boolean to say if the number is prime or not and I don't know much C, anyone care to give me some pointers? basically how i would do this in C# is like so: static bool IsPrime(int number) { for (int i = 2; i < number; i++) { if (number % i == 0 && i ...

C: how to apply a sequence of variables to a function?

In C, is there a way to call a function with arguments stored in some array? I'm a C newbie, I'm not even sure if this is right but e.g.: void f0(int a) { ... }; void f1(int a, int b) { ... }; void f2(int a, int b, int c) { ... }; int array[5][2][?] = [ [&f0, [5]], [&f1, [-23, 5]], [&f2, [0, 1, 2]], [&f2, [1235, 111, 42...

Why is the compiler throwing this warning: "missing initializer"? Isn't the structure initialized?

Hi, I'm creating some sort of frontend for a program. To launch the program I'm using the call CreateProcess(), which among other things receives a pointer to a STARTUPINFO structure. To initialize the structure I used to do: STARTUPINFO startupInfo = {0}; // Or even '\0'. startupInfo.cb = sizeof(startupInfo); When compiling the progr...

The cdecl calling convention

From: http://en.wikipedia.org/wiki/X86%5Fcalling%5Fconventions push c push b push a call function_name add esp, 12 ;Stack clearing mov x, eax Why do we need to explicitly add 12 to ESP to clear the stack since the called function should have poped the parameters off the stack therefore restoring the stack pointer...? Another questio...

size of struct and corresponding variable

If i define a char variable char a; and a structure with a single char member struct OneChar { char a; }; Will these both definitions have the size of 'char' in all compilers ? My doubt is, if we define a char variable in structure, due to memory packing will it take more size than size of char ? ...

Divide a string into smaller parts & organize a structure (C-programming)

Hi again! I am still learning C and I'm having some trouble figuring out how to handle this. Well, I have two structs: struct myStruct { ... struct myString *text[5]; ... } allStructs; struct myString { char part[100]; }; The objective is to have allStruct[n] point to 5 different parts of a text divided into lines of...

main() in C, C++, Java, C#

Is main() (or Main()) in C, C++, Java or C#, a user-defined function or a built-in function? ...

what is the good gvim guifont for C/C++ programming

I am trying to find an optimal font for gvim to program in C/C++. I currently have the following in ~/.gvimrc and I don't like it: if has("gui_gtk2") set guifont=MiscFixed\ 11 else set guifont=-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1 endif set columns=80 lines=50 set guioptions-=T "hide toolbar "Try to load h...

Public/Private Key Encryption in Java and C, Windows and Linux

I'd like to implement a software licensing scheme. I like the looks of the TrueLicense package in Java, but it's overkill, and I need to validate a license file not just in Java, but in C on both Windows and Linux. Can anyone suggest an approach and/or libraries or tools to validate an encrypted file across Java and C, Linux and Wind...

I have an embedded project idea that i want to start. I have many questions.

This is my first post on stackoverflow, I've heard of this website and I think its awesome! Let's see if i can get some guidance on how to start my project. The Idea: Basically I want to build my own custom OSC controller (OSC is a protocol based off UDP with the intention of replacing MIDI). What's interesting about this is that I want...

What API do I call to get the system uptime?

I would like to get the system uptime from within a C application running on a linux-based system. I don't want to call uptime(1) and parse the output, I'd like to call the underlying C API I suspect exists. Anyone know if there is such a call, or does uptime(1) simply process records obtained from wtmp? ...

What _did_ the C operators /\ and \/ do?

Anyone can "declare" ones own operators in C.... that is if one is a C compiler guru and has the source code to the C compiler! ;-) Further questions to puzzle: How are these operations done in C99? gcc? ... And why were /\ & \/ dropped? Which types were the /\ and \/ operators valid for? Googling for "/\ \/" naturally returns nothi...

Computing high 64 bits of a 64x64 int product in C

Howdy folks, I would like my C function to efficiently compute the high 64 bits of the product of two 64 bit signed ints. I know how to do this in x86-64 assembly, with imulq and pulling the result out of %rdx. But I'm at a loss for how to write this in C at all, let alone coax the compiler to do it efficiently. Does anyone have any ...

typedefs of structs not seeming to go through in header files?

I'm having some trouble with some struct typedef declarations in a header file not seeming to go through to my implementation file. Specifically, I have the following types defined: Type, Value, Integer, String, and Float. They are all typedef'd from struct names, in the exact same manner. I'm writing an informal hashCode function to su...

FLOPS what really is a FLOP

Hey everyone, I came from this thread: http://stackoverflow.com/questions/1536867/flops-intel-core-and-testing-it-with-c-innerproduct As I began writing simple test scripts, a few questions came into my mind. Why floating point? What is so significant about floating point that we have to consider? Why not a simple int? If I want to ...

Search for Binary Pattern in C (Read buffered binary file)

Hey there. I'm trying to write a small program that will read the four following bytes after the last occurrence of "0xFF 0xC0 0x00 0x11" which can be converted easily to binary or decimal. The purpose is that the 2-5 bytes following the last occurrence of that hex pattern represent the width and height of a JPEG file. #include <stdio.h...

how can I write an ANSI C console screen buffer?

I'm working on making an ASCII based game, and everywhere I look people are saying to use Console.Write() from MSDN, which is dandy and all if you're using Windows, but I'm not. And thus, I'm trying to write a function, or group of functions in C that can alternate between two screen buffers, and write them to the screen, similar to wha...

C Programming Pointers

I don't understand why is the last code block generating 1819043176 1870078063 6581362 0 1 2 3 4 0 6488159... These numbers are not random, but why those numbers? Thank you! int main(void) { int x; int y[10]; int* p; char* q; int k; char* prefix; k = 0; while (k < 10) { y[k] = k; ...