Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc)
int a=2,b=3,c;
c=a++ + a-- + b++ + b--;
printf("%d",c);
and
int a=2,b=3;
int c=a++ + a-- + b++ + b--;
printf("%d",c);
in first case ans comes 10 but in second case ans comes 12 why?
...
On Linux, I need to find the currently configured timezone as an Olsen location. I want my (C or C++) code to be portable to as many Linux systems as possible.
For example. I live in London, so my current Olsen location is "Europe/London". I'm not interested in timezone IDs like "BST", "EST" or whatever.
Debian and Ubuntu have a file /...
I have a GtkEntry where the user has to enter an IP number or a hostname. When the button is pressed what the user typed into the entry is added to a char. How can I programmatically check if this char contains spaces, the newline character or the tab character? I don't need to remove them, just to know if they exist. Thanks in advance!
...
I am working on an open source project which uses C for libraries, C++ for GUI and Cmake for managing build. This project is just started and have only couple of files. I can successfully generate makefiles on my linux development environment and on windows I can generate Visual Studio project files using CMake. All works well so far.
A...
Hello,
I try to call
g_io_scheduler_push_job(job_func, ¶m, NULL, G_PRIORITY_HIGH, generator_cancellable);
In my C/gtk+ application for runing job_func in another thread then main program. But have segfault when i call this function, and debugger sad that: ** userdata attempt to difference a generic pointer**
My job_func:
gbool...
I'm new to Windows development, having messed around in Linux for a while. I need to access console functions and am having trouble getting a comprehensive list of console text attributes off the web. I would like to read wincon.h and windows.h to get the info, but I can't figure out how to get at them. Help please!
...
I want to create a button that is basically Windows' close button. How could I do this? I want to avoid drawing this myself because I want it to look like that version of Windows' close button. Firefox's tabs do something like this. Thanks
...
If a=1, b=2, c=3... i would like to write a macro which concatenates them like this 123.
But when i try this:
#include<stdio.h>
#define cat(a,b,c) a##b##c
int main()
{
int a=1,b=2,c=3,d;
d=cat(1,2,3); //Works
d=cat(a,b,c); // Returns an error...How to make this work?
return 0;
}
...
Hi,
My company develops a primarily C-based API, using IDLs to define the interfaces and generate the C headers. We'd like to use Doxygen to document the interfaces in the IDLs, but we'd also like the API reference to document the C headers. In other words, the fact that we are using IDLs should be transparent to the customers of our ...
I'm just getting started with Doxygen, and have done considerable searching on this, so forgive me if there's an obvious answer.
I'm working on an embedded project where functions can be tagged as debug or nodebug before the return type. In most of our libraries, we use a conditional macro to set libname_debug to either debug or nodebu...
I prefer to define certain macros inside of my struct definitions, so it's easy to see possible values for a given member. For example:
typedef struct foo_t {
uint16_t flags;
#define FOO_FLAG_BELL 0x0001
#define FOO_FLAG_BOOK 0x0002
#define FOO_FLAG_CANDLE 0x0004
#define FOO_FLAG_LANT...
I'm trying to use an API for a proprietary interface device on an embedded system (Freescale HCS08), and the provided files include headers (.h) and libraries (.lib). The header compiles fine with the rest of my code (standard C), but when trying to link against the library I get memory errors saying the file might be corrupted.
My und...
Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc)
Hi,
if
x = 10, y=11
then, can anyone please explain why
int temp = x++ + ++y + x++;
then, temp has a value: 33
but
x = x++ + ++y + x++;
then, x has value: 34
and when
x = ++x + ++y + x++
then, x has value: 35
Com...
I have a directory with 50 .c source files and each one of these .c files depends on a .h file with the same name plus a common header file.
Example:
foo.c depends on foo.h and common.h
bar.c depends on bar.h and common.h
baz.c depends on baz.h and common.h
Is it possible to setup this dependency without having to make a separate tar...
Hi, I wish to get strings from the buffer of raw bytes in the memory, will work well?
static int in = 0;
void *loadFile (FILE *fp)
{
fseek (fp, 0L, SEEK_END);
size_t size = ftell (fp);
fseek (fp, 0L, SEEK_SET);
char *buf = malloc (sizeof(char) * size);
if (!buf)
return NULL;
if (fread (buf, sizeof...
Because it's always easier to see code...
My parser fills this object:
typedef struct pair {
char* elementName;
char* elementValue;
} pair;
My interpreter wants to read that object and fill this one:
typedef struct thing {
char* label;
} thing;
Should I do this:
thing.label = pair.elementName;
or this:
thing.label = (char*)...
I'm in the process of choosing a scientific library to use as a basis for a project. I need to do a lot of statistical, linear algebra, and signal processing tasks, and I figured there are probably some great libraries that already do this stuff better than I could program it myself.
For c++, I know about Boost, but don't have much expe...
Suppose we have to use in some function deeply nested pointer very extensively:
function (ptr_a_t ptr_a) {
...
a = ptr_a->ptr_b->ptr_c->val;
b = ptr_a->ptr_b->ptr_c->val;
...
}
Assuming all pointers are checked and valid, is there performance degradation, problems with atomicity or other caveats (except readability) in...
I know I can do this if I have a struct tm structure, but what if I want to do the same thing with a SYSTEMTIME. I could do this manually but just wondering if there's function that does this already.
Thanks
void PrintTimeSCII(struct tm *time)
{
char timebuf[26] = {0};
asctime_s(timebuf, 26, time);
printf("%s\n", time...
I want to write a function which randomizes the order of a sequence of alphabetic characters. For example, the sequence:
A B C D E F G . . .
...might be changed to:
Z L T A P ...
...which, if passed to the same function again could result in:
H R E I C ....
Any suggestions?
...