question
stringlengths 24
425
| answer
stringlengths 5
405
|
---|---|
```
fd1 = open("/dev/test_kft" "1",00);
```
What does"/dev/test_kft" "1"mean?
| It's implicit concatenation as performed by the compiler. It results in"/dev/test_kft1".
|
I am currently working on a linux daemon that needs to be single instance (i.e restricted to 1 user 1 process). What would be the best way of doing so without having to usegetpid()to manually write the pid out to/var/run/and then lock it usingflock()?
| Wrap the start-up and shut-down withstart-stop-daemon.
|
Is it safe to do something like the following?
```
#include <stdio.h>
#include <malloc.h>
#include <string.h>
int main(void)
{
char* msg;
strcpy(msg, "Hello World!!!"); //<---------
printf("%s\n", msg);
return 0;
}
```
Or should the following be used?
```
char* msg = (char*)malloc(sizeof(char) * 15);
```
| strdup does the malloc and strcpy for you
```
char *msg = strdup("hello world");
```
|
I installed the build-essential package for ubuntu x86_64, compiling c programs and c++ programs work fine, but in the compiled binary, "Ubuntu linaro" appears. is there a way to remove this?
| You can remove it using a hex editor. And may i ask why do you want to remove it??
|
Say I have a wrapper function for each file system related system calls e.g, open(), close(), creat() etc and inside each wrapper function I need to find out the process id of the process making the syscall. Would be gratefull for some pointers. Thanks....
| You're probably looking for thegetpid(2)system call; but Jeremiah asks good questions. :)
|
```
main()
{
char s[] = "abcdef", *p;
for (p = &s[5]; p >= s; p--) --p*;
puts(s);
return 0;
}
```
The compiler says there is a problem with --p* (expected an expression)?????
| --p*doesn't make any sense .
Probably you meant--*por--p?
Your code prints`abcdewhen the underlying representation is ASCII. BTW C99 mandates the return type ofmain()to beintin a hosted environment.
|
I am porting a Linux code that uses<unistd.h>, specifically gethostid function, to Windows 7.
I need an unique number of 32 bits that I will use in my application. How can I obtain an unique number using API from Windows 7 in the same manner that I do on Linux?
Thanks.
| You would normally implement this by returning the local IP address, for example by callinggetaddrinfo().
|
So I was wondering if there is like a centralized library management for C? likerubygemsfor C? I realized it might be a silly idea, but there are times when I wish I could have the benefits of rubygems, but for C.
| Mostpackage management systemshave entries for C libraries.
|
```
main()
{
char s[] = "abcdef", *p;
for (p = &s[5]; p >= s; p--) --p*;
puts(s);
return 0;
}
```
The compiler says there is a problem with --p* (expected an expression)?????
| --p*doesn't make any sense .
Probably you meant--*por--p?
Your code prints`abcdewhen the underlying representation is ASCII. BTW C99 mandates the return type ofmain()to beintin a hosted environment.
|
I am porting a Linux code that uses<unistd.h>, specifically gethostid function, to Windows 7.
I need an unique number of 32 bits that I will use in my application. How can I obtain an unique number using API from Windows 7 in the same manner that I do on Linux?
Thanks.
| You would normally implement this by returning the local IP address, for example by callinggetaddrinfo().
|
I am porting a Linux code that uses<unistd.h>, specifically gethostid function, to Windows 7.
I need an unique number of 32 bits that I will use in my application. How can I obtain an unique number using API from Windows 7 in the same manner that I do on Linux?
Thanks.
| You would normally implement this by returning the local IP address, for example by callinggetaddrinfo().
|
So I was wondering if there is like a centralized library management for C? likerubygemsfor C? I realized it might be a silly idea, but there are times when I wish I could have the benefits of rubygems, but for C.
| Mostpackage management systemshave entries for C libraries.
|
It is said that stl vector is "layout-compatible with C".
Where can I find the definition of "layout-compatible with C"?
| This means that, as long as the vector is not empty,&vector.front()will give you a pointer to a contiguous array of objects, which could be passed to a C API that expects such an array.
|
I know my file pointer is at end of the line after printing this string: "xyz".
How can I get it to the start of the line? (pointing to x)
```
offset = ftell(fp);
fseek(fp, offset - sizeof("xyz") , SEEK_SET);
```
Above doesn't seem to work.
How can I achieve that?
| I would store the offset by issuing abeginning = ftell(fp)before reading/writing you "xyz".
Thenfseek(fp, beginning, SEEK_SET);
Would this be possible?
|
I have a 3rd party library that reads RTMP packets from a network socket, using recv() and taking the socket descriptor as an argument. I want it to read these packets from the application buffer instead (allocated in heap).
Is it possible?
| You may be able to usesocketpair, which creates a pair of connected (unix domain) sockets. If you are on Linux, You can stuff the socket usingvmsplice, otherwisesend()as usual.
|
I've just started learning C and haven't been doing any memory management up to now. Can anyone recommend a good guide/tutorial for memory management in C?
| I think the biggest thing to wrap your head around is storage and lifetime of variables in memory (stack vs heap). You can check outWikiBook's treatment of this topic. I find it to be a gentler introduction to a lot of topics.
|
For example, can the output of 'uname -a' be used to create the COMPILED_ON macro below?
```
#include <stdio.h>
#define COMPILED_ON `call uname -a and use the output as a quoted string'
int main( int argc, char **argv ) {
printf( COMPILED_ON );
return 0;
}
```
| no, but:
```
gcc -DCOMPILED_ON="$(uname -a)"
```
|
This question already has answers here:Closed12 years ago.
Possible Duplicate:How does system() exactly work in linux?
For the sake of my curiosity,
I want to know that how does system() function spawn the process and its internal implemenation ?
Is is using fork , exec internally ?
| On my Debian box it uses clone() that itself calls sys_clone(). You can use strace to look at system calls.
|
Is there a way to find out in which function/file/line set the current errno?
| Not that I know of,it's just a global static int (no magic in it)(see comment below).
You're supposed to check after each function that could set it when it returns an error.
|
How can I insert or remove a word in the middle of a text file using C on Linux?
| Copy the whole file to a temporary location by adding/omitting the word to remove, replace the original source by the temporary file.
There's also the possiblity to use fseek()http://www.manpagez.com/man/3/fseek/
|
Is this ok?
```
char buf[] = { 0, 1, 2 };
memcpy(buf, buf + 1, 2);
```
Does having a bigger datatype make any difference? I know I could use memmove(), but I'm just curious.
| The effects ofmemcpyare not defined when the input and output overlap. You should usememmove.
|
Is it possible to put the equivalent of#define VAR(in a C program) into a makefile, so that one can control which part of the program should be compiled?
| Accordingly toccmanpage onlinux
```
-D name=definition
The contents of definition are tokenized and processed as if they appeared during translation phase three in a #define directive. In
particular, the definition will be truncated by embedded newline characters.
```
|
I want to display the binary tree as a Max Heap order.
Requirement
1) Input - Binary Tree
2) Output - Max Heap / Min Heap
Thanks a lot.
REgards,
Girija
| If you are allowed to use other's work:
Use std::make_heap to make a heap from a vector
|
I want to display the binary tree as a Max Heap order.
Requirement
1) Input - Binary Tree
2) Output - Max Heap / Min Heap
Thanks a lot.
REgards,
Girija
| If you are allowed to use other's work:
Use std::make_heap to make a heap from a vector
|
I have a DVB receiver (set-top box) similar likeDreamboxand it has MIPS cpu
It hasembedded Linuxand I can connect to it withtelnet
Question is how to compile simple "Hello World" application inC? Where to gettoolchain,SDK?
| You should useCodescape SDK.
|
Can i store the unspecified type in GtkListStore? For instance, I want to store in one field - the field of int type and the field of GdkColor type ?
| I think you meanunions in C C++
|
Is there a way I could get the inode number of a file which has not yet been opened. I would like to do this from inside a c function
Regards,
Lipika
| Usestat(2)(which takes a file path), and check the st_ino field. Do note that it's possible for someone to move or remove the file between the time you callstatand whenever you manage to do anything with the information.
|
I read INI file strings through GetPrivateProfileString API. However, the INIs in local windows directory could be read like that.
How can I read and edit a INI file in a Remote machine.
| You should not expect to be able to modify INI files stored on remote machines. Whatever your problem is, this is not the solution.
|
How do I read command-line parameters in C? For example, in
```
./test --help
```
or
```
./test --build
```
how do I access "--build" or "--help"?
| Your parameters are in argv:
```
int main(int argc, char **argv)
```
if you printf the content of argv (argv[0],argv[1] etc) youll get the idea.
try:
```
int main (int argc, char **argv)
{
for(int i = 0;i< argc;i++)
printf("%s\r\n",argv[i]);
}
```
|
```
char *xyz()
{
char str[32];
strcpy(str,"Hello there!");
return(str);
}
void main()
{
printf("%s",xyz());
}
```
When I call xyz(), is it will return a dangling pointer ?
Thanks
| Yes, it is a dangling pointer. Your program invokes undefined behaviour.
On some systems it might crash your application, on others it might appear to work correctly. But either way, you should not do it.
|
is there a C macro or some kind of way that i can check if my c program was compiled as 64bit or 32bit at compile time in C?
Compiler: GCC
Operating systems that i need to do the checks on: Unix/Linux
Also how could i check when running my program if the OS is capable of 64bit?
| Since you tagged this "gcc", try
```
#if __x86_64__
/* 64-bit */
#endif
```
|
I read INI file strings through GetPrivateProfileString API. However, the INIs in local windows directory could be read like that.
How can I read and edit a INI file in a Remote machine.
| You should not expect to be able to modify INI files stored on remote machines. Whatever your problem is, this is not the solution.
|
How do I read command-line parameters in C? For example, in
```
./test --help
```
or
```
./test --build
```
how do I access "--build" or "--help"?
| Your parameters are in argv:
```
int main(int argc, char **argv)
```
if you printf the content of argv (argv[0],argv[1] etc) youll get the idea.
try:
```
int main (int argc, char **argv)
{
for(int i = 0;i< argc;i++)
printf("%s\r\n",argv[i]);
}
```
|
```
char *xyz()
{
char str[32];
strcpy(str,"Hello there!");
return(str);
}
void main()
{
printf("%s",xyz());
}
```
When I call xyz(), is it will return a dangling pointer ?
Thanks
| Yes, it is a dangling pointer. Your program invokes undefined behaviour.
On some systems it might crash your application, on others it might appear to work correctly. But either way, you should not do it.
|
is there a C macro or some kind of way that i can check if my c program was compiled as 64bit or 32bit at compile time in C?
Compiler: GCC
Operating systems that i need to do the checks on: Unix/Linux
Also how could i check when running my program if the OS is capable of 64bit?
| Since you tagged this "gcc", try
```
#if __x86_64__
/* 64-bit */
#endif
```
|
How would you compare strings when the characters(and)should come after the alphanumeric characters. Do I have to write a function or is there any library function available?
Thank you for your answers!
| You can usestd::lexicographical_comparewith a custom predicate. That predicate should take 2 chars, and return false if the first should come before the second.
|
Should I write OpenGL program by using C or C++? Really confused.
| You can use either. The OpenGL API is in C and C++ is backward compatible with C. Just choose your favourite language.
|
I'm patching an OTP module (yubico_pam) and I'm trying to access thecontrol-flagselected by the administrator (e.g.required, sufficient, etc).
Any idea? Is this feasible at all (without parsing the file)?
| There's no way to query this information within the API. We have to avoid the need of knowing this value or specifically instruct the user on what control-flag he should use.
|
Each side is 60 degrees. and the top and bottom sides are horizontal
I thinkwidth = (cos(60) * sideLength * 2) + sideLength = sideLength * 2
This seems a bit off
| width should be2*sideLength(sideLength = cos(60) * sideLength * 2)
height will besin(60) * sideLength * 2 = sqrt(3)*sideLength
|
I'm trying to figure out if this could somehow be overflowed:
```
void print_address(char *p)
{
arp_ hw;
int i;
hw.length = (size) *(p + _OFFSET1); //189 + 4 = 193
memcpy(hw.addr, packet + _OFFSET2, hw.length);
return;
}
```
where packet is an input read from a .txt file?
| Yes, it can be overflowed; if the value at offset 4 in the packet is greater than 128, you will overflow theaddrfield inhwaddr.
|
I'm patching an OTP module (yubico_pam) and I'm trying to access thecontrol-flagselected by the administrator (e.g.required, sufficient, etc).
Any idea? Is this feasible at all (without parsing the file)?
| There's no way to query this information within the API. We have to avoid the need of knowing this value or specifically instruct the user on what control-flag he should use.
|
Each side is 60 degrees. and the top and bottom sides are horizontal
I thinkwidth = (cos(60) * sideLength * 2) + sideLength = sideLength * 2
This seems a bit off
| width should be2*sideLength(sideLength = cos(60) * sideLength * 2)
height will besin(60) * sideLength * 2 = sqrt(3)*sideLength
|
I.E., you enter the number 5, and the character A and the output would yield F. I have no idea how to even start to go about this, any give me a push in the right direction?
| Individual characters are represented by numbers according to theASCII code(usually). In C, if you add a number to a character, you're shifting the character down. Try:
```
char c = 'A';
int n = 5;
printf("%c\n", c + n);
```
|
I'm making a program which controls other processes (as far as stopped and started states).
One of the criteria is that the load on the computer is under a certain value.
So i need a function or small program which will cause the load to be very high for testing purposes. Can you think of anything?
Thanks.
| I can think of this one :
```
for(;;);
```
|
I have a program which forks off other processes. The arguments to my program include the process name of the process to be forked, along with any arguments.
This means, when I make the call to exec(), I need to be able to handle however many arguments were supplied.
Any ideas?
Thanks.
| Theexecvfunction takes a pointer to an array of arguments.
Just like inmain, the last element in the array needs to be a null pointer.
|
```
static struct K { int x; };
```
Is this valid in C and C++?
| In C, it's valid butuseless.
In C++ it's invalid. You can only specify storage class for objects and functions.
|
I am searching for a solution to delete all files from my pendrive using a C program. I don't want the code to detect the pendrive as that's not a concern right now. I would appreciate any links that could help me out on this.
Note: I am working on Windows 7 64-bit and I want to delete the entire contents from my pendrive, which contains .exes and .dlls.
Thanks and Regards,
Radix
| The non-hackcorrectway to do this, is via theVirtual Disk Service.
|
```
const int size = 10; // realna ilość danych
int tablica[size+1];
```
i have:variable-size type declared outside of any function
| Use
```
#define size 10
```
instead of aconst int. The latter is not a compile-time constant in C, but a variable that cannot be assigned to (unless via a pointer and a cast to get rid ofconst).
(This is a difference between C and C++.)
|
I just readhttp://olstrans.sourceforge.net/release/OLS2000-ext3/OLS2000-ext3.htmlwhich is an excellent review of the design issues used when journaling was implemented in ext3. Could someone point me towards the section of the linux kernel code where ext3 journaling is implemented?
| You can uselxrto search the linux code.
ext3 and journaling interface code ishereand JDB code ishere
|
Is the strtok function in standard C89?
| the man page says:
```
CONFORMING TO
strtok()
SVr4, POSIX.1-2001, 4.3BSD, C89, C99.
strtok_r()
POSIX.1-2001.
```
So I would say yes.
According to the C89 draft I have (the actual standard costs money), the appropriate section is:
4.11 STRING HANDLING <string.h>4.11.5.8 The strtok function
|
Is there any way to execute Linux commands with c without usingexeclp(), like predefined functions or something else.
Thanks.
| Usesystem()orpopen()if you need the commands output.
|
There is a code snippet,
```
int matchhere(char *regexp, char *text)
{
/* do sth */
return *test== '\0';
}
```
I do not understand what does
```
return *test== '\0';
```
mean. Or what it will return? How does "==" function here?
| compare*testto'\0', return 0 if inequal, return 1 if equal.
|
Is there easy way to create FILE* from WinApi HANDLE which points to one end of pipe?
Something like we do in unix:fdopen(fd,<mode>);
| You can do this but you have to do it in two steps. First, call_open_osfhandle()to get a C run-time file descriptor from a Win32 HANDLE value, then call_fdopen()to get aFILE*object from the file descriptor.
|
I am doing it wrong, yes?
```
...
if( you_think_youre_genius )
goto goto_sucks:
...
pthread_mutex_lock(&mutex);
do_stuff();
goto_sucks:
do_other_stuff();
pthread_mutex_unlock(&mutex);
```
| Yes, goto is direct jmp down at the binary code level soanyfunction calls between the goto and the label will be skipped, period.
|
I have:
printf("%.2s\n", &s[2]);
How can I represent that as a chosen value?
So I would want something like:
printf(%.%is\n", someInt, &s[2]); #
but this doesnt work, where %i is someInt
| You wantprintf("%.*s\n", someInt, &s[2]);. Consult theprintf man pagefor more details.
|
In C, how to remove all characters present in one array from another array?
| Sounds like homework but here's a solution.
Make an array of 256 entries, likechar set[256].
Read the first string. For each charactercsetset[(unsigned char)c]to 1.
Read and copy the second string. For each charactercifset[c]then skipc.
I forgot and left out that you must firstmemset(set, 0, sizeof(set))before setting any of its values to 1.
|
So:
```
char *someCArray; # something
```
I want to print out "ethin" from "something".
| You can use theprintfprecision specifier
```
#include <stdio.h>
int main(void) {
char s[] = "something";
int start = 3;
int len = 5;
printf("%.*s\n", len, s + start);
return 0;
}
```
Code also posted to codepad:http://codepad.org/q5rS81ox
|
Why do local variables use Stack in C/C++?
| Technically, C does not use a stack. If you look at theC99 standard, you'll find no reference to the stack. It's probably the same for the C++ standard, although I haven't checked it.
Stacks are just implementation details used by most compilers to implement the C automatic storage semantics.
|
Is there any way to execute Linux commands with c without usingexeclp(), like predefined functions or something else.
Thanks.
| Usesystem()orpopen()if you need the commands output.
|
There is a code snippet,
```
int matchhere(char *regexp, char *text)
{
/* do sth */
return *test== '\0';
}
```
I do not understand what does
```
return *test== '\0';
```
mean. Or what it will return? How does "==" function here?
| compare*testto'\0', return 0 if inequal, return 1 if equal.
|
Is there easy way to create FILE* from WinApi HANDLE which points to one end of pipe?
Something like we do in unix:fdopen(fd,<mode>);
| You can do this but you have to do it in two steps. First, call_open_osfhandle()to get a C run-time file descriptor from a Win32 HANDLE value, then call_fdopen()to get aFILE*object from the file descriptor.
|
I am doing it wrong, yes?
```
...
if( you_think_youre_genius )
goto goto_sucks:
...
pthread_mutex_lock(&mutex);
do_stuff();
goto_sucks:
do_other_stuff();
pthread_mutex_unlock(&mutex);
```
| Yes, goto is direct jmp down at the binary code level soanyfunction calls between the goto and the label will be skipped, period.
|
I have:
printf("%.2s\n", &s[2]);
How can I represent that as a chosen value?
So I would want something like:
printf(%.%is\n", someInt, &s[2]); #
but this doesnt work, where %i is someInt
| You wantprintf("%.*s\n", someInt, &s[2]);. Consult theprintf man pagefor more details.
|
In C, how to remove all characters present in one array from another array?
| Sounds like homework but here's a solution.
Make an array of 256 entries, likechar set[256].
Read the first string. For each charactercsetset[(unsigned char)c]to 1.
Read and copy the second string. For each charactercifset[c]then skipc.
I forgot and left out that you must firstmemset(set, 0, sizeof(set))before setting any of its values to 1.
|
So:
```
char *someCArray; # something
```
I want to print out "ethin" from "something".
| You can use theprintfprecision specifier
```
#include <stdio.h>
int main(void) {
char s[] = "something";
int start = 3;
int len = 5;
printf("%.*s\n", len, s + start);
return 0;
}
```
Code also posted to codepad:http://codepad.org/q5rS81ox
|
I have the following line of code:
```
contents[pos++] ^= key[shift++];
```
What does operator^=mean?
| It is theXORassignment operator. Basically:
```
x ^= y;
```
is the same as:
```
x = x ^ y;
```
|
I'm trying to generate a random number that's between 0 and 1. I keep reading aboutarc4random(), but there isn't any information about getting a float from it. How do I do this?
| Random value in[0, 1[(including 0, excluding 1):
```
double val = ((double)arc4random() / UINT32_MAX);
```
A bit more detailshere.
Actual range is[0, 0.999999999767169356], as upper bound is (double)0xFFFFFFFF / 0x100000000.
|
I'm searching with brute force for a floating point number with certain properties (small roundoff error of sin(a)^2+cos(a)^2-1). I therefore want to loop over the neighborhood of a given floating point number by incrementing the significand.
Is there a simple way to do that in C?
| C99 has nextafter and nexttoward; they weren't present in C90.
|
What is the best way to generate an HTTP session ID and avoid collisions as much as possible? How long should my session ID be?
| Just use a Guid. This will very hard to get a duplicate one.
|
Has a way to get the datatype in C?
For example:
```
int foo;
if (foo is int)
{
// do something
}
```
or something like:
```
if (typeof(foo) == typeof(int))
{
// do something
}
```
Thanks in advance.
| This is called type introspection or reflection and is not supported by the C language. You would probably have to write your own reflection library, and it would be a significant effort.
|
```
char copy, array[20]
printf("enter ..."):
scanf("%s", array);
if (strlen(array) > 20 )
{
strcpy(copy, array....);
```
what would I need to do to make it only grab the first 20 character if the input is more then 20 character long
| ```
char array[20+1];
scanf("%20s", array);
```
Problem solved.
|
What is the best way to generate an HTTP session ID and avoid collisions as much as possible? How long should my session ID be?
| Just use a Guid. This will very hard to get a duplicate one.
|
Has a way to get the datatype in C?
For example:
```
int foo;
if (foo is int)
{
// do something
}
```
or something like:
```
if (typeof(foo) == typeof(int))
{
// do something
}
```
Thanks in advance.
| This is called type introspection or reflection and is not supported by the C language. You would probably have to write your own reflection library, and it would be a significant effort.
|
```
char copy, array[20]
printf("enter ..."):
scanf("%s", array);
if (strlen(array) > 20 )
{
strcpy(copy, array....);
```
what would I need to do to make it only grab the first 20 character if the input is more then 20 character long
| ```
char array[20+1];
scanf("%20s", array);
```
Problem solved.
|
I'm wondering if there would be any merit in trying to code astrlenfunction to find the\0sequence in parallel. If so, what should such a function take into account? Thanks.
| strlen()is sequential by spirit - one step beyond the null-terminator is undefined behavior and the null-terminator can be anywhere - the first character or the one millionth character, so you have to scan sequentially.
|
hi every one i want to ask that i want to compare two time values in c how can i do it
time is in form
```
Sat Feb 19 12:53:39 2011
```
thanks
| You need to parse the human readable form viastrptime()and convert to atime_t-- which is (unsigned) integer seconds since the epoch of Jan 1, 1970. As that is a number, usual comparison operators apply.
|
I came across this question:
"Given an integer, write a program that converts the given number to a number (in base 10). The given number could be in any base, but the base is unknown."
Provide an algorithm
Thanks in advance.
| Usestrtolto convert from whatever base to your computer's native integer format. Then useitoato convert to a base 10 representation.
|
This pageprovides lots of libraries to handle item resizing and re-adjustment, but they're all for C++. Is there anything I can use for plain C?
| You can call MoveWindow() do not only move but also resize Windows and Dialogs:
http://msdn.microsoft.com/en-us/library/ms633534%28VS.85%29.aspx
|
Is it possible to replace BuildAll of Eclipse CDT by a Makefile?
I mean I have a Makefile in C and I would buildall from this file. I build a Target in Eclipse to compile but I would use the Ctrl+B to buildall. My environment is Eclipse-Cdt.
| There is no problem in creating a makefile that would invoke other make files.
But achieving interaction between Eclipse and the makefile would be extremely hard.
|
hi every kindly tell me how to display pointer position
for eg
fpos_t pos;
(fgetpos(fp, &pos)
how to disply pos value
thanks
| To do this portably you're not supposed to try and display that pos value.
Try using ftell() instead.
```
long pos;
pos = ftell(fp);
printf("pos is %ld bytes\n", pos);
```
|
I am making a program in c that can produce another c code.
How to, using the first program, compile and run the second program immediately after the second program has been produced?
| One way is to usedsystem()call ...
```
system("cl generated_file.c -o gen_exe") ;
system("./gen.exe");
```
or
```
system("gcc generated_file.c -o gen.exe");
system("./gen.exe");
```
Or you use a simle batch or script or makefile to do this
|
What conditions are necessary for open() to fail, with UDP sockets, on Windows?
Thanks.
| The only time I've seen that happen is when I didn't initialize WinSock with WSAStartup().
|
When creating aGtkNotebookin Glade, I get 3 tabs by default. How can I add another tab?
| Right-click on one of the tabs, and click "Insert page before" or "Insert page after".
|
How to catch click on balloon tray icon?
What message it sends to window?
Scenario:
The application shows balloon and user clicks on some point in the balloon space or to close button on balloon form.
| The message you get sent is always the one you passed to Shell_NotifyIcon. The lParam of the message will be NIN_BALLOONUSERCLICK. You don't get to find out whether the user clicks the close button or not.
|
I am trying to find a good way to handle multicast group members.Keep track when someone joins/leaves the group. Language is C.
| Unless you are implementing an IP multicast router you should add a subscription management protocol above multicast in the application layer.
|
```
unsigned char x = 93;
unsigned char a = x << 4;
printf("a = %d\n", a);
```
I do understand how bit operators work but I don't understand the binary representation of x.
How is a = 208?
| ```
93 = 01011101
```
Shift that left 4 bits and it leaves the following (only 8 bits in your result):
```
11010000 = 208
```
|
I want to learn OpenGL ES, but so far I don't know anything about it and I was wondering if there is a tutorial which stars from 0 knowledge. Remember that I don't know anything about graphics, drawing, etc.
| This is a great start since it's specific to iPhone:
OpenGL ES from the Ground Up: Table of Contents
|
Is there a c atoi() equivalent for wide chars on Linux? I can find something for MS (wtoi) but I can find anything in a standard Linux lib.
| You can usewcstolto convert from wide strings to integer values.
|
This method in Cocos2d:
```
/** Returns opposite of point.
@return CGPoint
@since v0.7.2
*/
static inline CGPoint
ccpNeg(const CGPoint v)
{
return ccp(-v.x, -v.y);
}
```
Why does it say 'CGPoint' after inline? Why not
```
static inline ccpNeg(...
```
?
| Because the function wants to return a CGPoint.
|
I want to learn OpenGL ES, but so far I don't know anything about it and I was wondering if there is a tutorial which stars from 0 knowledge. Remember that I don't know anything about graphics, drawing, etc.
| This is a great start since it's specific to iPhone:
OpenGL ES from the Ground Up: Table of Contents
|
Is there a c atoi() equivalent for wide chars on Linux? I can find something for MS (wtoi) but I can find anything in a standard Linux lib.
| You can usewcstolto convert from wide strings to integer values.
|
In reference to the thread:memmove implementation in C, I did not understand why would there be a memory overlap for 2 different variables? i.e. is this a normal scenario that the compiler allocates same 'common space' to 2 different variables and why is this policy used by compilers in such cases?
| Nothing to do with the compiler. Consider the following:
```
int x[100];
memmove(&x[1], &x[0], 99*sizeof(int));
```
|
```
x=4+2%-8;
```
This gives output=6
Please anyone explain how?
| x=4+2%-8;is equivalent tox = 4 + (2 % -8);which givesx = 4 + 2which is 6.
More:C Operator Precedence Table
|
I have a simple question
How to simply convert integer (getting values 0-8) to char, e.g. char[2] in C?
Thanks
| ```
main()
{
int i = 247593;
char str[10];
sprintf(str, "%d", i);
// Now str contains the integer as characters
}
```
Hope it will be helpful to you.
|
In reference to the thread:memmove implementation in C, I did not understand why would there be a memory overlap for 2 different variables? i.e. is this a normal scenario that the compiler allocates same 'common space' to 2 different variables and why is this policy used by compilers in such cases?
| Nothing to do with the compiler. Consider the following:
```
int x[100];
memmove(&x[1], &x[0], 99*sizeof(int));
```
|
```
x=4+2%-8;
```
This gives output=6
Please anyone explain how?
| x=4+2%-8;is equivalent tox = 4 + (2 % -8);which givesx = 4 + 2which is 6.
More:C Operator Precedence Table
|
I have a simple question
How to simply convert integer (getting values 0-8) to char, e.g. char[2] in C?
Thanks
| ```
main()
{
int i = 247593;
char str[10];
sprintf(str, "%d", i);
// Now str contains the integer as characters
}
```
Hope it will be helpful to you.
|
```
x=4+2%-8;
```
This gives output=6
Please anyone explain how?
| x=4+2%-8;is equivalent tox = 4 + (2 % -8);which givesx = 4 + 2which is 6.
More:C Operator Precedence Table
|
I have a simple question
How to simply convert integer (getting values 0-8) to char, e.g. char[2] in C?
Thanks
| ```
main()
{
int i = 247593;
char str[10];
sprintf(str, "%d", i);
// Now str contains the integer as characters
}
```
Hope it will be helpful to you.
|
I am wondering what the difference is between these two variables in C:
```
float price = 3.00;
```
and
```
float price = 3.00f;
```
What is the use of suffixfin this case?
| 3.00is interpreted as adouble, as opposed to3.00fwhich is seen by the compiler as afloat.
Thefsuffix simply tells the compiler which is afloatand which is adouble.
SeeMSDN (C++)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.