If I want to make an OS X program as self-contained as possible to ease installation, what dynamic libraries can I expect everyone or most people to have? If I know that, I won't have to compile static libraries for everything.
...
I realise you can just #define some integers, but why didn't C have a dedicated boolean data type before C99?
It's such a common occurence in programming and logic, I don't understand the absense of an explicit type and notation.
...
When malloc is called, the size is stored adjacent to the allocated block so that free will know how much to free etc ( http://c-faq.com/malloc/freesize.html ).
My question is, Say we have dynamically allocated memory and later in the code we increment the pointer
pointer++
And then later, if i call a
free(pointer)
what memor...
I am writing a program which if I compiler on Suse 10 32 bit system without adding the -m32 option and execute it on Suse 10 64 bit works fine.
In this case is it not required for me to add -m32 option?
Can we execute programs built on 32 bit systems directly on their 64 bit counterparts without any side-effects? Or any updates or cha...
I have a sequence.
a1 = 1 - cos(x);
ai = a1 + (-1)^(i-1) * x^(2*i-2) / (2*i-2)!
I need to write this with and without recursion. But it has a different results.
Here is my code: http://codepaste.net/q213q6
...
What languages other than C and C++ have explicit reference and pointer type qualifiers? People seem to be easily confused by the right-to-left reading order of types, where char*& is "a reference to a pointer to a character", or a "character-pointer reference"; do any languages with explicit references make use of a left-to-right readin...
I am having some problems writing to a file in unicode inside my c program. I am trying to write a unicode Japanese string to a file. When I go to check the file though it is empty. If I try a non-unicode string it works just fine. What am I doing wrong?
setlocale(LC_CTYPE, "");
FILE* f;
f = _wfopen(COMMON_FILE_PATH,L"w");
fwprintf(f,L"...
Why does the array a not get initialized by global variable size?
#include<stdio.h>
int size=5;
int main()
{
int a[size]={1,2,3,4,5};
printf("%d",a[0]);
return 0;
}
The compilation error is shown as "variable-sized object may not be initialized".
According to me the array should get initialized by size.
and what would be...
I was looking for a tool that can convert C code expressions for the form:
a = (A) ? B : C;
into the 'default' syntax with if/else statements:
if (A)
a = B
else
a = C
Does someone know a tool that's capable to do such a transformation?
I work with GCC 4.4.2 and create a preprocessed file with -E but do not want such structures...
Hello,
I am writing a simple console application which will allow me to create a number of threads from a set of parameters passed through the arguments I provide.
DWORD WINAPI ThreadFunc(LPVOID threadData)
{
}
I am packing them into a struct and passing them as a parameter into the CreateThread method and trying to unpack them by ca...
What are the rules? OTOH the simple case seems to imply the new type is the last thing on a line. Like here Uchar is the new type.
typedef unsigned char Uchar;
But a function pointer is completely different. Here the new type is pFunc:
typedef int (*pFunc) (int);
I can't think of any other examples offhand but I have come across...
I have functions that I wish to call based on some input. Each function has different number of arguments. In other words,
if (strcmp(str, "funcA") == 0) funcA(a, b, c);
else if (strcmp(str, "funcB") == 0) funcB(d);
else if (strcmp(str, "funcC") == 0) funcC(f, g);
This is a bit bulky and hard to maintain. Ideally, these are variadic f...
I'm not quite sure why if I try to free the data I get segfault. Any help will be appreciate it.
struct mystu {
char *q;
};
static GHashTable *hashtable;
static void add_inv(char *q)
{
gpointer old_key, old_value;
if(!g_hash_table_lookup_extended(hashtable, q, &old_key, &old_value)){
g_hash_table_insert(hashtable, g...
I have a string "14 22 33 48". I need to insert each of the values in the string into the respective location in the array:
int matrix[5];
so that
matrix[0] = 14;
matrix[1] = 22;
matrix[2] = 33;
matrix[3] = 48;
How do I do this?
...
Hi,
I have a c program which I can launch at command prompt.
Is it possible for me the lunch this application in my another c program?
If yes, how? All the google result shows me how to do that using pthread? Will that work?
I suspect that I need a new process for my c program.
Thank you.
...
Is there a canonical colorspace conversion library? I can't find any pre-existing solutions. Is CIELab conversion is too obscure?
...
I need a way to obtain a local (not WAN) address of an incoming telnet or ssh
session using a shell script or C.
...
symbol.h:179: note: expected ‘uintptr_t *’ but argument is of type ‘PRECEDENCE’
The corresponding code is :
176 void symbol_SetCount(SYMBOL, unsigned long);
177 unsigned long symbol_GetCount(SYMBOL);
178
179 size_t symbol_Ordering(uintptr_t*, SYMBOL);
180
181 void symbol_CheckIndexInRange(int);
182...
I'm working with an embedded system, and I'm ending up with a ton of HW-interfacing #define functions. I want to put all of these into a separate file (for OOP-ness), but I don't know the best way to #include that. Do I just put them all into a .c file, then include that? Seems silly to put these in a .h file.
...
When reading about pipes in Advanced Programming in the UNIX Environment, I noticed that after a fork that the parent can close() the read end of a pipe and it doesn't close the read end for the child. When a process forks, does its file descriptors get retained? What I mean by this is that before the fork the pipe read file descriptor...