question
stringlengths 24
425
| answer
stringlengths 5
405
|
---|---|
Namely code similar to this, making the printout undefined.
```
int a=41; a++ & printf("%d\n", a);
```
I don't know what exactly this operation is called.
| The problem is that it is not specified which is evaluated first, theprintfor thea++, and since one has a side effect on the other (you either readathen write it then read it again, or read it then read it then write it), you get undefined behaviour.
|
Namely code similar to this, making the printout undefined.
```
int a=41; a++ & printf("%d\n", a);
```
I don't know what exactly this operation is called.
| The problem is that it is not specified which is evaluated first, theprintfor thea++, and since one has a side effect on the other (you either readathen write it then read it again, or read it then read it then write it), you get undefined behaviour.
|
I'm looking for a cross-platform(works at UNIX-like and Windows) library to handling operating system date. Is there it for C programmers? or C++ if really have no for C. Thanks in advance!
| Perhaps you should tryBoost.Date_Time.
|
please find thecodefor the service created to detect my USB device.
The problem in the above code is that the logfile is getting updated only after the service is stopped.
My intension is to update the log file once the device is detected.. But it happens only after the service is stopped. how to achieve what i intend to?
please guide me..
| To avoid losing log entries, you need to flush thefwrites .
fflush(your file handle )
|
please find thecodefor the service created to detect my USB device.
The problem in the above code is that the logfile is getting updated only after the service is stopped.
My intension is to update the log file once the device is detected.. But it happens only after the service is stopped. how to achieve what i intend to?
please guide me..
| To avoid losing log entries, you need to flush thefwrites .
fflush(your file handle )
|
Does calloc allocate return contiguous memory location? If yes, what would it do if it is not available?
| Does calloc allocate returns contiguous memory location?
Yes.1
what would it do if it is not available?
ReturnNULL.
See section 7.20.3.1 of the C99 standard.
1. So far as the C program is concerned. In a virtual memory system, the underlying physical memory used may not be contiguous.
|
I'm reading through some code for an Arduino example and I came across this line:
uint16_t pulses[100][2];
It appears that this is defining a 100x2 array -- is that correct?
| You are correct. It defines a 100x2 array of unsigned 16 bit integers.
|
How to get the id of a specific edge with two of its vertex?
Example:
egde id=4 with vertex 2 and 3, using id 2 and 3 vertex how to get the id=4 of that edge?
| igraph_get_eidis the function you are looking for.
|
How to get the id of a specific edge with two of its vertex?
Example:
egde id=4 with vertex 2 and 3, using id 2 and 3 vertex how to get the id=4 of that edge?
| igraph_get_eidis the function you are looking for.
|
I know that in h264 we can detect a NAL Unit by the bit pattern0x000001.
Is there an equivalent method to detect a slice header in a NAL Unit? How does one handle multi-slice NAL units?
Currently I'm using parsing code for h264 and get the slice header in a respective structure.
| The slice header syntax is discussed on page 36 (section 7.3.3) of theH.264 standard.
It might be worth having a look at thereference software.
|
I have the following C statement:
```
int res = x & (x ^ y);
```
Is there a way to do the same thing, but usingxandyonly one time each?
For example:
```
x | (~x & y) == x | y
```
| Yes, by expanding the xor (a ^ b == (a & ~b) | (~a & b)), and then simplifying the result, one gets:
```
res = x & ~y;
```
|
I need a library to list files in archives and to extract archive files. The library should support archive types as much as possible. Do you have any suggestion ?
Any help would be appreciated.
| This sounds like you are looking for libarchivehttp://libarchive.github.com/
|
I have the following C statement:
```
int res = x & (x ^ y);
```
Is there a way to do the same thing, but usingxandyonly one time each?
For example:
```
x | (~x & y) == x | y
```
| Yes, by expanding the xor (a ^ b == (a & ~b) | (~a & b)), and then simplifying the result, one gets:
```
res = x & ~y;
```
|
I have the following C statement:
```
int res = x & (x ^ y);
```
Is there a way to do the same thing, but usingxandyonly one time each?
For example:
```
x | (~x & y) == x | y
```
| Yes, by expanding the xor (a ^ b == (a & ~b) | (~a & b)), and then simplifying the result, one gets:
```
res = x & ~y;
```
|
I need a library to list files in archives and to extract archive files. The library should support archive types as much as possible. Do you have any suggestion ?
Any help would be appreciated.
| This sounds like you are looking for libarchivehttp://libarchive.github.com/
|
I came across the below declaration ; what will be the scope of this MACRO ?
```
typedef struct Hdr_s {
#define MACRO1 1
#define MACRO2 2
#define MACRO3 3
unsigned char Flag;
unsigned char Offset;
unsigned short cpy_len_offset;
unsigned char cpy_offset;
}Hdr_t;
```
| A macro definition remains for the whole remainder of the compilation, and macros aren't scoped.
|
I needed to execute a loop and a condition in every second or in the interval of a few milliseconds. What can I do to achieve this?
| ```
#include <unistd.h>
```
usleepfor POSIX platform (hight precision sleep)
|
Is it possible to hack the Chrome (more precisely the Webkit's), through an extension, in order to use my own media server instead of Google's one?
It's needed to make realtime voice interactive app and I'm looking to an alternatives instead of doing this in flash or a Java Applet.
| I found (for my projects) that usingVideoIO.swfandRTMPLiteis far easier and more portable solution.
|
I knowgetppidretrieves the parent pid of the underlying program, but how can you tell this out of that program? I can't find anything useful in/proc/[pid], or is there any useful API that i can use?
UPDATE
I mean , i'm inspecting these procress with another process , so getppid won't work here
| It is the fourth field in /proc/[pid]/stat. It is documented in the man pageproc(5).
|
I know some difference between char* and char[].char x[] = "xxxx"Is an array of chars;char *y = "xxxx"is a pointer to the literal (const) string;
Andx[4]=='\0', and*(y+4) == '\0'too.
So whysizeof(x)==5andsizeof(y)==4?
| char x[] = "xxxx"is an array of size 5 containing x x x x and \0.
char *y = "xxxx"is a pointer to a string. It's length is 4 bytes, because that is the length of the pointer, not the string.
|
One of my questions, as I'm pretty new to C is about ways to avoid getting the duplication error. Basically, when I build the project in Netbeans if I have the file in the project and also include it, I get that error.
Defining the functions static, is a correct way to avoid it? What other solutions are there? Thanks
| .c/.cppfiles shouldn't be included.
Move declarations to a common header file and include that.
|
Say I have this file:http://www.example.com/somepic.png
Is there a cross platform C or C++ library that could easily allow me to download it to a specified directory?
Thanks
| You can uselibcurlto do this.
|
I knowgetppidretrieves the parent pid of the underlying program, but how can you tell this out of that program? I can't find anything useful in/proc/[pid], or is there any useful API that i can use?
UPDATE
I mean , i'm inspecting these procress with another process , so getppid won't work here
| It is the fourth field in /proc/[pid]/stat. It is documented in the man pageproc(5).
|
I know some difference between char* and char[].char x[] = "xxxx"Is an array of chars;char *y = "xxxx"is a pointer to the literal (const) string;
Andx[4]=='\0', and*(y+4) == '\0'too.
So whysizeof(x)==5andsizeof(y)==4?
| char x[] = "xxxx"is an array of size 5 containing x x x x and \0.
char *y = "xxxx"is a pointer to a string. It's length is 4 bytes, because that is the length of the pointer, not the string.
|
One of my questions, as I'm pretty new to C is about ways to avoid getting the duplication error. Basically, when I build the project in Netbeans if I have the file in the project and also include it, I get that error.
Defining the functions static, is a correct way to avoid it? What other solutions are there? Thanks
| .c/.cppfiles shouldn't be included.
Move declarations to a common header file and include that.
|
Say I have this file:http://www.example.com/somepic.png
Is there a cross platform C or C++ library that could easily allow me to download it to a specified directory?
Thanks
| You can uselibcurlto do this.
|
I did search but I did't find any BPF code to use on my computer, also there isn't any example code to use. My goal is to find low level functions to filter packets. I am working in C program language. I am using Ubuntu 12.04 with 3.2.0 kernel.
| You may want to look into thepcaplibrary, from the folks who brought you tcpdump. Pcap is a cross-platform packet filtering library with support for BPF filters.
|
I need to panic kernel after some operations are done and verify what operation did
Can some one help me to know if there is any way? I searched a lot but no luck
I am looking for some generic call
thanks in Advance!
| You can try asysrq trigger:
```
echo c > /proc/sysrq-trigger
```
'c' - Will perform a system crash by a NULL pointer dereference.
A crashdump will be taken if configured.
|
Let us say in some part of the code that a macro has been defined. During compilation, I want to learn if it has been defined and is being used. How might I do this?
| Check with#ifndefdirective and throw an error with#errordirective :
```
#ifndef A_MUST_HAVE_MACRO
#error "A must have macro not defined"
#endif
```
|
I am trying to write a code that can get the names of the installed drivers in my Windows computer in C (via winapi)?
I am really new to C and I do not know what I can do ? Can you please help me with this situation ?
Thank you very much
| You need the setup API. Start with this article:How to enumerate hardware devices by using SetupDi calls
|
As per my understanding there are two RSA signature schemes - PSS (Probabilistic Signature Scheme) and the old PKCS1-v1_5:
Can I use RSA_verify() API to check RSA signature under both schemes ?
| If you have a recent version - see:http://fixunix.com/openssl/526614-signing-verifying-messages-rsassa-pss.htmlfor how to use it.
|
I have downloaded rx. Can somebody please tell of a suitable ide for debugging and building the source code of "rdf-3x". As per the operating system: ubuntu & Windows are both fine for me.
I tried netbeans (C++) but it does not work for me, since it does not treat all the folders within as one project, rather it treats them as separate projects.
| I'm using Eclipse..
It's user friendly for me..You can try it.http://www.eclipse.org/cdt/
CMIIW
|
Can any one tell me how to typecast achar*pointer toint*in OpenCL kernel function??
I tried((int*) char_pointer)but it is not working.
| You have to qualify the pointer with the correct address space, I think.
If you don't specify the address space,__privateis assumed, but your source pointer seems to be a__globalpointer (from your comment), so the address spaces are incompatible.
So try to use(__global int*)instead of just(int*).
|
is there an open implementation for an aztec 2D barcode (for the Deutsche Bundesbahn) generator. I do not need the "aztec-data to bitmap", but i need the "input-data to aztec-data" part, the drawing itself is no problem with drawing primitives.
| ZXingalso supports Aztec encoding since version 2.2.
|
This question already has answers here:How would I load a PNG image using Win32/GDI (no GDI+ if possible)?(5 answers)Closed9 years ago.
Very simple question: how do I render a png image with GDI in C (including its transparencies)?
| I went with GDI+ instead of GDI.
|
Can any one tell me how to typecast achar*pointer toint*in OpenCL kernel function??
I tried((int*) char_pointer)but it is not working.
| You have to qualify the pointer with the correct address space, I think.
If you don't specify the address space,__privateis assumed, but your source pointer seems to be a__globalpointer (from your comment), so the address spaces are incompatible.
So try to use(__global int*)instead of just(int*).
|
is there an open implementation for an aztec 2D barcode (for the Deutsche Bundesbahn) generator. I do not need the "aztec-data to bitmap", but i need the "input-data to aztec-data" part, the drawing itself is no problem with drawing primitives.
| ZXingalso supports Aztec encoding since version 2.2.
|
This question already has answers here:How would I load a PNG image using Win32/GDI (no GDI+ if possible)?(5 answers)Closed9 years ago.
Very simple question: how do I render a png image with GDI in C (including its transparencies)?
| I went with GDI+ instead of GDI.
|
Is there a way to tell (on UNIXes) which of a process's memory pages are in the RAM and which have been swapped out?
| Not in a portable way.
Even if it were possible, it would be mostly useless. A page you have checked is swapped in could very well be swapped out the moment you are ready to use it.
|
What is the direct alternative for thevsnwprintffunction on linux machines and what headers should be included to use it?
Thanks for any advice
| It depends on whatvsnwprintf()(sic)does and what is its parameter list.
TheC99 Standarddescribesvswprintf()(in section 7.24.2.7). To use it you need to #include<stdarg.h>and<wchar.h>. The implementation should be in the Standard library.
|
I need to pass some arguments to my application,that include the - symbol. The problem is if I passgdb a.out -foo baa, the gdb understand that the arguments are for it, and not to my application. How to fix this?
| gdb -q a.outinside gdb:run -foo baaTip: -q option for gdb suppresses the introductory copyright messages.
|
this is a simple question ... is there a way to convert astruct tm ct;to a long integer ? here's how my code look like:
```
struct tm ct;
scanf("%d", &ct.tm_sec);
scanf("%d", &ct.tm_min);
scanf("%d", &ct.tm_hour);
scanf("%d", &ct.tm_mday);
scanf("%d", &ct.tm_mon);
scanf("%d", &ct.tm_year);
```
| You can use themktime()function to convert astruct tminto atime_t, which is an integer value.
|
I run a program with LD_PRELOADing a specific library. Like this.
```
LD_PRELOAD=./my.so ./my_program
```
How do I run this program withgdb?
| Do the following.
```
gdb your_program
(gdb) set environment LD_PRELOAD ./yourso.so
(gdb) start
```
|
What is the direct alternative for thevsnwprintffunction on linux machines and what headers should be included to use it?
Thanks for any advice
| It depends on whatvsnwprintf()(sic)does and what is its parameter list.
TheC99 Standarddescribesvswprintf()(in section 7.24.2.7). To use it you need to #include<stdarg.h>and<wchar.h>. The implementation should be in the Standard library.
|
```
int a[2]={1210,15};
printf("%d",a[33] );
```
OUTPUT
```
1073828132
```
Why it's not throwing error when i'm trying to printa[33]even though the array element doesn't exist
| Because C does not do bounds-checking.
You will just be reading an arbitrary location in yourcall stack.
|
In which section is constant volatile variable stored in c.? In micro-controllers we should put such kind of variables in RAM. Right?
| Volatilehas noting to do with where the variable is stored. It just tells the compiler to read the variable from memoryevery timeto avoid any optimization that compiler might perform for that variable.
|
```
int a[2]={1210,15};
printf("%d",a[33] );
```
OUTPUT
```
1073828132
```
Why it's not throwing error when i'm trying to printa[33]even though the array element doesn't exist
| Because C does not do bounds-checking.
You will just be reading an arbitrary location in yourcall stack.
|
In which section is constant volatile variable stored in c.? In micro-controllers we should put such kind of variables in RAM. Right?
| Volatilehas noting to do with where the variable is stored. It just tells the compiler to read the variable from memoryevery timeto avoid any optimization that compiler might perform for that variable.
|
I tried this but it's not working for me:
```
char * remove_nl(char * newstr)
{
newstr = strdup(newstr);
newstr[strlen(newstr)-1] = '\0';
return newstr;
}
```
| What you have now is fine, except:
you have to make sure thatnewstrpoints to a valid string;check thatstrlen(newstr) > 0;check thatnewstr[strlen(newstr)-1]is indeed a newline before wiping it;make sure the callerfree()s the returned string.
|
Canglibcbe compiled into one object file which can then be linked to any program. The main purpose is portability here. Because I don't require to install dynamic libraries this way. Can this be done? If so, how?
| You can compileglibcto.afiles which can be linked into a static executable. The static libraries are built by default.
|
I was looking into some old code in my product and i found following code.
```
#include <stdio.h>
#include <string.h>
int main ( int argc, char **argv) {
const char *str = "abcdefghi";
int value = strcmp(str, "abcdefghi") == 0;
}
```
What is the purpose ofint value = strcmp(str, "abcdefghi") == 0;of such code.
| It initializesvaluewith the result ofstrcmp(str, "abcdefghi") == 0which will be0or1depending on whatstrcmpreturns.
|
I have many native libraries with a C API that contain functionality I want to use in a web app. What choices are out there (frameworks/languages) for doing this?
| To call native C functions from C#, including ASP.Net, use P/Invoke. It exists for exactly that purpose.
Tutorial Here:http://msdn.microsoft.com/en-us/library/aa288468(v=VS.71).aspx
|
I need to run a command,but that don't lock my application until exit of it,like dosystem()function.
| Usefork()to create a new process, andexec*()to replace it with a new application.
|
in C, I have to send a bunch of datas with tcp/ip (~6.5mo)
I'm using the "classic" send().
Do you think it's a good idea to give to the function the whole size of data to send in one part or should I prefer the chunk way (slices of, for example, 64ko...)
| Give it the full size, and just call it again with the rest of the buffer (according to the return value).
You deal with your logic, let the OS deal with the send logic.
|
I need to run a command,but that don't lock my application until exit of it,like dosystem()function.
| Usefork()to create a new process, andexec*()to replace it with a new application.
|
in C, I have to send a bunch of datas with tcp/ip (~6.5mo)
I'm using the "classic" send().
Do you think it's a good idea to give to the function the whole size of data to send in one part or should I prefer the chunk way (slices of, for example, 64ko...)
| Give it the full size, and just call it again with the rest of the buffer (according to the return value).
You deal with your logic, let the OS deal with the send logic.
|
If I have a socket and someone sent data to it that I didn't yet handle viaread(), and now I make anev_iowatcher for it and run it, will the callback fire?
| I don't know the answer to your question as I've never usedlibev. But I can suggest in the absence of this knowledge you might try to simulate the scenario and see what happens. :-)
|
I came across to a question from one of my friend.
What is the difference between these?
```
* char ptr
char * ptr
```
| This is an error:
```
* char ptr;
```
This declaresptras a variable of type pointer-to-char:
```
char * ptr;
```
|
This question already has answers here:Closed11 years ago.
Possible Duplicate:C pointer to array/array of pointers disambiguation
How ischar (*p)[4];different fromchar *p[4];?
| http://cdecl.org/
char (*p)[4];-- declare p as pointer to array 4 of char.char *p[4];-- declare p as array 4 of pointer to char.
|
I'm looking to save an HBITMAP to a PNG image. Is this possible using only the GDI API? (I'm using C, so no GDI+.) I have only found examples likethis, to save to a BMP file. Or should I uselibpngand useGetDIBits?
Related question(about reading).
| Unfortunately, GDI does not support PNGs.
|
This question already has answers here:How to compare ends of strings in C?(25 answers)Closed7 years ago.
How can I check whether a string ends with.csvin C?
I've tried usingstrlenwithout any success.
| How about:
```
char *dot = strrchr(str, '.');
if (dot && !strcmp(dot, ".csv"))
/* ... */
```
|
Sorry for such a simple question, but does anyone have a C example of initializing the MSP430 for SPI mode and performing poll read and write operations? Very new stuff to me and am not sure where to start.
Thanks.
| You might have a look atMSP430Warewhich is "a collection of code examples, datasheets and other design resources for ALL MSP430 devices..."
|
Is there a library like Python's httplib for C?
I am asking because I want to write a C program that creates an HTTPSConnection.
Thanks.
| libcurl is indead the most famous, but there are also a lot of alternativeshere.
|
How do i initialize a variable of structure B or C?
```
typedef struct _A
{
union
{
struct
{
int b;
} B;
struct
{
int c;
} C;
} u;
} A;
```
Something likeA.u.B *bVar;doesn't work
| Thetypedefonly coversA, not the union or structures defined therein.
typedefcan't be nested like that - each user-defined "type" must have a single label, so a declaration of a variable of typeA.u.Bis illegal.
|
As we know the integer storage length is 4 bytes and character storage is 1 byte.Here comes my problem,I have a huge data and I need to write them into a file.
For eg. my data is like
```
Integers - 123456789 (of length 9) (Total 9! factorial records)
Character - abcdefghi (of length 9) (Total 9! factorial records)
```
Which one will take less processing time? Any thoughts...
| It's insignificant compared to the file's access time.
|
I have a program that uses_mm_crc32_u64. I include the header filesmmintrin.hfor that purpose and also use the flag-msse4.1when compiling it withgcc. However, when I compile it I getundefined reference to _mm_crc32_u64error. What is the problem here?
| I did it like this and it worked! So basically I had to use msse4.2 instead of msse4.1.
```
gcc44 crc.c -msse4.2
```
|
How do you explain the Rounding happening here?I thought assigning float values to Int's always cause loss of value after decimal?
```
int z=39.99999999999999999999999;
printf("%d",z); // gives 40
```
Thanks
| You can't have a double precise enough to hold all those 9s.
```
>>> '%.15f' % 39.9999999999999
'39.999999999999901'
>>> '%.15f' % 39.99999999999999
'39.999999999999993'
>>> '%.15f' % 39.999999999999999
'40.000000000000000'
```
|
How do you explain the Rounding happening here?I thought assigning float values to Int's always cause loss of value after decimal?
```
int z=39.99999999999999999999999;
printf("%d",z); // gives 40
```
Thanks
| You can't have a double precise enough to hold all those 9s.
```
>>> '%.15f' % 39.9999999999999
'39.999999999999901'
>>> '%.15f' % 39.99999999999999
'39.999999999999993'
>>> '%.15f' % 39.999999999999999
'40.000000000000000'
```
|
I am working on an assignment that deals with using various data structures to store and sort data. The data structures portion is fairly straight forward to me, however, I am getting hung up on the first step, reading/parsing a wtmp file. I've parsed several files previously, but never have I parsed a binary file. What's the trick to parsing such a file? Thanks in advance.
| Try usingutmp.h.
|
I have created one file that contains (degree celcius character) and other character that required more then one byte. In Notepad++ it shows encode ANSI and as it is ANSI then why Notepad shows that multibyte character ?
Any idea ?
Thanks,
Neel
| If you don't save it in UNICODE! Notepad will save it in ANSI as long as the codepage supports the characters involved.
To save in UNICODE you must select that from the drop-down list when saving a file.
|
c89
gcc (GCC) 4.6.3
Hello,
I am getting a stack dump on *search = '\0'; I thought it was possible to nul terminate a string.
```
char *ptr_name = "hello@home";
char *search = ptr_name;
search = strchr(ptr_name, '@');
search++;
*search = '\0';
```
Many thanks for any suggestions,
| ptr_name points to a string in read-only area.
Instead try :
```
char ptr_name[] = "hello@home"
```
|
How can I find that an IP address is a LAN IP address or WAN IP address? I am writing a C API in Windows.Thanks
| Most likely, what you want to determine is whether the address is a global address, or aprivate address. The wikipedia article lists the address blocks that are reserved for private use.
|
c89
gcc (GCC) 4.6.3
Hello,
I am getting a stack dump on *search = '\0'; I thought it was possible to nul terminate a string.
```
char *ptr_name = "hello@home";
char *search = ptr_name;
search = strchr(ptr_name, '@');
search++;
*search = '\0';
```
Many thanks for any suggestions,
| ptr_name points to a string in read-only area.
Instead try :
```
char ptr_name[] = "hello@home"
```
|
How can I find that an IP address is a LAN IP address or WAN IP address? I am writing a C API in Windows.Thanks
| Most likely, what you want to determine is whether the address is a global address, or aprivate address. The wikipedia article lists the address blocks that are reserved for private use.
|
I need to create a dump file when there is an exception.
Is it possible to do so without using__try{...}and__except(e){...}?
Is there a way to create a callback function or register an action waiting for a system crash?
Thanks in advance.
| Yes, you can usesignalto register a callback for a specific signal, including exceptions.
|
I need to create a dump file for a customer program written in C.
I saw that there is a minidump for windows, is it working only on C++ ?
Is there any other solution for C language?
Thank you for your time.
| See this excellent tutorial:http://www.debuginfo.com/articles/effminidumps.html. It uses Win32 APIMiniDumpWriteDump, so its pure C.
|
```
static char* theFruit[] = {
"lemon",
"orange",
"apple",
"banana"
};
```
I know the size is 4 by looking at this array. How do I programmatically find the size of this array in C? I do not want the size in bytes.
| ```
sizeof(theFruit) / sizeof(theFruit[0])
```
Note thatsizeof(theFruit[0]) == sizeof(char *), a constant.
|
I was under the impression that the math library is linked statically because-l namelinks tolibname.a, however if I try to compile with the-staticflag, suddenly GCC can't find the math functions.
Does this means that math is not necessarily linked statically? Or is something else is going on here?
| If it would compile statically you would writegcc libname.ainstead ofgcc -l libname.
And to your question, yes math library is linked dynamically.
|
Well, I need develop applications for Windows mobile 6.1/6.5 and I'm looking for how to do this using C language programming. I heard that it's possible, but so far not found anything about, just support for C++/CLI programming language on older versions of VS.
| UseeMbedded Visual C++ 4.0.
It is free, too.
Just an FYI, though: IMO: Visual Studio 2008 is MUCH faster at getting stuff done.
|
In an extension, what can I do to avoid the crash of the php engine when zval string is allocated by myself ?
```
..
// will do implicitly ZVAL_STRING("tmp", "/tmp", 0);
//
SET_VAR_STRING("tmp", "/tmp");
..
php_embed_shutdown(TSRMLS_C); // GPF !!
```
Any ideas?
| Change it to:
```
SET_VAR_STRING("tmp", estrdup("/tmp"));
```
|
I'm trying to set the cursor to a watch. The problem is that gdk_set_cursor() requires a gdk_window.
How do I get the gdk_window of a gtk_window in C? I've seen examples for gtkmm and pygtk but I can't find the corresponding C function.
| ```
GdkWindow *gdk_window = gtk_widget_get_window(GTK_WIDGET(gtk_window));
```
or, pre GTK 2.14, but now disallowed:
```
GdkWindow *gdk_window = gtk_window->window;
```
|
Well, I need develop applications for Windows mobile 6.1/6.5 and I'm looking for how to do this using C language programming. I heard that it's possible, but so far not found anything about, just support for C++/CLI programming language on older versions of VS.
| UseeMbedded Visual C++ 4.0.
It is free, too.
Just an FYI, though: IMO: Visual Studio 2008 is MUCH faster at getting stuff done.
|
In an extension, what can I do to avoid the crash of the php engine when zval string is allocated by myself ?
```
..
// will do implicitly ZVAL_STRING("tmp", "/tmp", 0);
//
SET_VAR_STRING("tmp", "/tmp");
..
php_embed_shutdown(TSRMLS_C); // GPF !!
```
Any ideas?
| Change it to:
```
SET_VAR_STRING("tmp", estrdup("/tmp"));
```
|
I want a function which will block until an interface is bound/unbound for OS X (i.e. the equivalent of Windows'NotifyAddrChange. Anyone know how to do this?
| You are looking forSCNetworkReachability, take a look atthe reference.
Note that you need to include<SystemConfiguration/SystemConfiguration.h>to use it.
|
I'm using the C-style GTK functions in C++ and I can't figure out how to set the cursor for the main window.
| Usegdk_set_cursor()
(https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-set-cursor)
on a GdkCursor created bygdk_cursor_new()
(https://developer.gnome.org/gdk3/stable/gdk3-Cursors.html)
|
I am building source on Windows using Cygwin, I need to find places with memory leaks and possible memory leaks. I know about Valgrind used for memory leak detection in Linux.
Can Valgrind be used along with Cygwin so that it works in a Windows based environment?If yes can you please tell what configurations, etc. are needed?
| No it'snotsupported.
Also, an obvious link:http://www.google.com/search?q=cygwin+valgrind
|
I am building source on Windows using Cygwin, I need to find places with memory leaks and possible memory leaks. I know about Valgrind used for memory leak detection in Linux.
Can Valgrind be used along with Cygwin so that it works in a Windows based environment?If yes can you please tell what configurations, etc. are needed?
| No it'snotsupported.
Also, an obvious link:http://www.google.com/search?q=cygwin+valgrind
|
With lock files I mean: Create a file to lock a resource and delete it when releasing it again.
| Directly from the man page:
```
NOTES
flock() does not lock files over NFS. Use fcntl(2) instead: that does work over NFS, given
a sufficiently recent version of Linux and a server which supports locking.
```
I'm not saying using lock files is the better option over NFS, though.
|
I have made a small program in c# called Registry.exe.
Now i my c++ program i want to call this Registry.exe is there a way to do it.
User cannot give any inputs the call is to be based on conditions
| You cann simply use
system("Registry.exe");
|
I am generating an XML file using libxml2. In one of the tags i want to put the current time in"dd mm yyyy hh mm sec"format.
My dev environment is C/LINUX.
Thanks !
| Usestrftime. Check the manual page for details.
|
Is it possible to have an overflow (wrap around) with a double or a float? What will happen if the maximum (or minimum) value is reached on x86 or x64 hardware?
| On an IEEE-754 compliant system, overflow results in a special "infinity" (or "minus infinity") value, beyond which any further increment will have no effect.
|
Instead of
```
cardNumber = j+1;
deck[i][j] = cardNumber;
theDeck[k] = cardNumber;
```
is it valid to just say
```
deck[i][j] = theDeck[k] = cardNumber;
```
to assign cardNumber to both deck and theDeck at the same time??
| Yes, it is. The assignment operator returns a value.
|
I have made a small program in c# called Registry.exe.
Now i my c++ program i want to call this Registry.exe is there a way to do it.
User cannot give any inputs the call is to be based on conditions
| You cann simply use
system("Registry.exe");
|
I am generating an XML file using libxml2. In one of the tags i want to put the current time in"dd mm yyyy hh mm sec"format.
My dev environment is C/LINUX.
Thanks !
| Usestrftime. Check the manual page for details.
|
Is it possible to have an overflow (wrap around) with a double or a float? What will happen if the maximum (or minimum) value is reached on x86 or x64 hardware?
| On an IEEE-754 compliant system, overflow results in a special "infinity" (or "minus infinity") value, beyond which any further increment will have no effect.
|
Instead of
```
cardNumber = j+1;
deck[i][j] = cardNumber;
theDeck[k] = cardNumber;
```
is it valid to just say
```
deck[i][j] = theDeck[k] = cardNumber;
```
to assign cardNumber to both deck and theDeck at the same time??
| Yes, it is. The assignment operator returns a value.
|
Given: The path of a file on a UNIX file system
How can I get the UUID of the device it is stored on, possibly with a library call from C, in a way that is the most portable amongst UNIX like system (including OS X)?
| You can callint stat(const char *path, struct stat *buf)and the buf->st_dev will give to you the device's ID.
stat() is POSIX.1.
|
Example : 2.3666%
And I am Using.
But Not Working..
```
float n = 2.3666;
NSLog(@"%f%",n);
```
| You need toescape percent signs using%%
```
float n = 2.3666;
NSLog(@"%f%%",n);
```
|
How can I "compile" Objective-C Code to (only) C-Code?There is a way to preprocess Objective-C in Xcode (Product -> Generate Output -> Generate Preprocessed File), but this is not what I'm looking for...
Thanks...
| clang (the compiler front-end used by Xcode nowadays) has a-rewrite-objcoption built-in, which allows you to generate C++ code based on Objective-C (or Objective-C++) code.
Just don't ask me how to combine that with Xcode.
|
I have this code
whitespaces is a type int, so I can use the getchar function
```
do
{
...code...
whitespaces=getchar();}
while ( whitespaces != (EOF) || whitespaces!='\n');
```
but it doesnt exit the loop when i hit CTRL+Z (i am using windows 7)
what am I doing wrong?
EDIT : thank you, all of you...! very helpful
| You must use&&instead of||in thewhilecondition.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.