cdev

1

votes
1

answer
210

views

declare member of struct as a pointer in c and use it

I have a uint8_t *C = malloc(24*sizeof(uint8_t)); I need to send some integers and this *C to another node(in ad hoc network). So I am going to use a struct struct fulMsg { int msgType; int msgCount; //uint8_t *CC; } fulMsg_t; typedef struct fulMsg fulMsg_tt;` there is a method called packetbu...
cdev
1

votes
2

answer
6.7k

views

How to compare two unsigned integers (uint8_t) in c

I have two uint8_t pointers in my program and I want to compare the values of those. I don't have good idea to deal with unsigned ints. Here is my code static void bacast_signed_message() { uint8_t *M = malloc(MAX_M_LEN*sizeof(uint8_t));//uint8_t M[MAX_M_LEN];//uint8_t *M; int M_len = MAX_M_LEN;; ui...
cdev
17

votes
2

answer
1k

views

Can isdigit legitimately be locale dependent in C

In the section covering setlocale, the ANSI C standard states in a footnote that the only ctype.h functions whose behaviour is not affected by the current locale are isdigit and isxdigit. The Microsoft implementation of isdigit is locale dependent because, for example, in locales using code page 125...
cdev
3

votes
1

answer
145

views

Array Declaration-Error in Java

Why int arr[][]=new int[5][]; declaration is perfectly fine but int arr[][]=new int[][5] generates compile time error ? Please do help me. I am not able to understand why is that so?
cdev
2

votes
0

answer
2.3k

views

Disable security features in Firefox

I am testing a website using selenium web driver. The particular site contains nested iframes. I cannot access content of Iframes, because of the Same Origin Policy. Therefore I disabled web security in chrome web driver and access those contents using following Jquery script. $(β€˜#data’).find(β€...
cdev
2

votes
5

answer
177

views

Is it undefined behaviour to call a 3rd party library function (not provided as source code)?

In C is it undefined behaviour to call a 3rd party library function (not provided as source code)? By this I mean: Not calls to the Standard C Library. Not calls to an additional library provided by the compiler vendor. Not calls to a library created by me using the C compiler. Not calls to a 3rd pa...
cdev
15

votes
3

answer
725

views

sizeof(β€œβ€+0) != sizeof(char *) Bug or undefined behaviour?

The following C program: #include int main(void) { printf('%u %u %u\n',sizeof '',sizeof(''+0),sizeof(char *)); return 0; } outputs 1 4 4 when compiled with GCC on Linux, but outputs 1 1 4 when compiled with Microsoft Visual C++ on Windows. The GCC result is what I would expect. Do they differ becau...
cdev
1

votes
2

answer
1.7k

views

Finding nth largest number (many times) when the array size is increasing

We can easily find the nth largest using the Median of Medians Algorithm in O(n) time complexity. If we have to find multiple times the nth largest numbers in the same array the best would be to sort O(NlogN) and then find the number in O(1) time complexity. But what will be the efficient algorithm...
cdev