I've tried everything Google-able, but can't seem to wrap my head around this. I'm trying to return a char and pass to another function with no luck. Do I need to do some sort of memory location?
char hostname[] = "www.XXXXX.com";
uint8 ipaddr[] = {XXX,XXX,XXX,XXX};
char uri[] = "/api/Login/";
char key[] = API_KEY; //34903240...
I'm currently using boost::thread, because it very conveniently allows me to pass an arbitrary number of arguments to the thread and copies them along the way, so I don't have to worry about them being deleted before the thread launches. Is there any other library that allows this, or a way to simulate it using pthreads? I'd like to wean...
how does a call from c++ to c work internally??
...
Hey internets. I am having a VERY strange issue in C. I am deriving a float value, and then checking to see if it is greater than 0. However, the comparison is always evaluating to true, even if the value is less than zero. Here is the code:
if (sVel > 0.0f)
{
sVel += 1.0f;
sVel -= 1.0f;
NSLog(@"SEP VEL: %1.6f", sVel);
...
hi, i wanted to convert double to float in C, but wanted to preserve the decimal point exactly as possible without any changes...
for example, let's say i have
double d = 0.1108;
double dd = 639728.170000;
double ddd = 345.2345678
now correct me if i am wrong, i know that floating point precision is about 5 numbers after the...
The objective is to build a "infinite" tree using dynamic arrays.
items[3]
- MENUITEM
- items[2]
- MENUITEM
-items[0]
- MENUITEM
- items[0]
- MENUITEM
- items[0]
- MENUITEM
- items[2]
- MENUITEM
- items[0]
- MENUITEM
- items[0]
I define the structure:
typedef struct MENUITEM {
char id...
I need to extract url from XML response. Here is the XML response:
<cloud xmlns:xlink="http://www.w3.org/1999/xlink">
<rootContainer xlink:href="https://api.example.net/v2/bucket/92FBC29C-344C-99CF-827E-1B5586A7F8E3"
xlink:type="simple"/>
</cloud>
I'm using C to write regex. Need help.
my output needs to be https://api...
I'm dealing with large numbers coming from the hash table. I'm wondering what would be a good way of adding them to a constant (100) taking into account portability. Glib's documentation highlights that using GINT_TO_POINTER is not portable in any way. Any ideas would be appreciated!
gpointer v, old_key;
gint value; // ?
if(g_hash_tab...
In limits.h, there are #defines for INT_MAX and INT_MIN (and SHRT_* and LONG_* and so on), but only UINT_MAX.
Should I define UINT_MIN myself? Is 0 (positive zero) a portable value?
...
Thanks to some very helpful stackOverflow users at Bit twiddling: which bit is set?, I have constructed my function (posted at the end of the question).
Any suggestions -- even small suggestions -- would be appreciated. Hopefully it will make my code better, but at the least it should teach me something. :)
Overview
This function wil...
Hey guys
Jus check out this program.Logically it seems fine but its giving 000000000000000000000 for everything
#include<stdio.h>
void main()
{
int n=25,k=32;
printf("binary equivalent\n");
while(k!=0)
{
if((n>>1&0x01)!=0)
printf("1");
else
printf("0");
k--;
}
}
...
Hey guys
Check out this code
#include<stdio.h>
int main()
{
const int a=7;
int *p=&a;
(*p)++;
printf("*p=%d\np=%u\na=%d\n&a%u",*p,p,a,&a);
getch();
}
The output you get for this is
*p=8
p=1245064
a=8
&a1245064
How is this possible?? We declared variable a as constant. Doesnt this mean that the location pointed to by a can ...
Hi friends~
When I develop in COM, I always see (void**) type conversion as below.
QueryInterface(/* [in] */ REFIID riid,/* [out] */ void** ppInterface)
What's exact meaning of it?
IMHO, it tells the compiler not to enforce type validation, since the type which is pointed by the ppInterface is not known to the client code at compil...
Apple introduced a closure in C as name of 'block'.
Should I manage memory for the blocks? If so, what do I have to do?
...
In binary search algorithm we have two comparisons:
if (key == a[mid]) then found;
else if (key < a[mid]) then binary_search(a[],left,mid-1);
else binary_search(a[],mid+1,right);
Is there a way by which I can have only one comparison instead of the above two.
--
Thanks
Alok.Kr.
...
Hi,
I am writing a program to leak memory( main memory ) to test how the system behaves with low system memory and swap memory. We are using the following loop which runs periodically and leaks memory
main(int argc, char* argv[] )
{
int arg_mem = argv[1];
while(1)
{
u_int_ptr =(unsigned int*) malloc(arg...
I keep getting these errors. Im trying to make a mine sweeper like game.
well.c: In function 'main':
well.c:170: warning: passing argument 1 of 'bombCheck' makes pointer from integer without a cast
well.c:170: warning: passing argument 3 of 'bombCheck' makes integer from pointer without a cast
well.c: In function 'fillGameBoard':
well....
When compiling C/C++ codes using gcc/g++, if it ignores my register, can it tell me?
For example, in this code
int main()
{
register int j;
int k;
for(k = 0; k < 1000; k++)
for(j = 0; j < 32000; j++)
;
return 0;
}
j will be used as register, but in this code
int main()
{
register int j;
int...
Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc)
int main()
{
int a=5,s;
s=++a + ++a;
printf("%d",a);
printf("%d",s);
}
output is 7 and 14
BUT
int main()
{
int a, s;
printf("Enter value of a");
scanf ("%d",&a);
s=++a + ++a;
printf("%d",a);
printf("%d",s);
}
input user give...
EDITED 8/18/2010
I have C code for Linux that, among other things, caches the difference between the rtc and system time. I want to port this code to FreeBSD/Mac. Linux has the utility hwclock which reads /dev/rtc and anyway getting the cmos clock time directly from this interface can be done in a few lines of code.
I've been lookin...