means is it like this
a[0] = 00000000 00000000 00000001 00101100
since my linux x86 architecture uses little-endian it is stored as 00101100 00000001 00000000 00000000
means answer will be different in case of Big-endian ??...
User Profile
Collapse
-
char * in array of int
output :: 44 1 0Code:int aa[3]={300,3,4}; char *p; p=aa; p=(char*)((int *)(p)); printf("%d",*p); p=(int*)(p+1); printf(" %d",*p); p++; printf(" %d",*p);
can someone help me with why this output is coming (especially 1 after 44) -
Which programming language should i learn
I'm currently in the final year of my b.tech . I'm quite comfortable with c/c++, now i want to learn some application oriented programming language which can be used to get things done. I tried java for few days, but it didn't seem to arouse any interest...need help from experts.
thanks -
typecasting using pointer
int *p, *q;
p= (int *) 60;
q= (int *) 20;
printf("%d", p-q);
the answer is 10
m lil unsure about wat does (int *) 60 means
if is it memory location numbered 60,as it seems...then it is possible that this memory area is not available so output should be undefined.
need help with this conceptual doubt -
yupp....both heap and stack memory should not be a problem as the same program is running fine with larger number of points but points being distributed relatively apart from each other(changing %100 of rand to bigger value) !!
Btw thanks for pointing out line 15 thing...'ll avoid such a thing in future....Leave a comment:
-
quickSortCloses tPair.c
...Code:// quicksort, if char==c then it sorts points acc. to x coordinate otherwise it sorts according to y coordinate void Swap(struct point **a, struct point **b); void QuickSort(struct point *aa[], int p, int r, char c); int Partition1(struct point *aa[], int p, int r); int Partition2(struct point *aa[], int p, int r); //sorts array of struct point according to index given by c
Leave a comment:
-
here's the code
...Code:#include<stdio.h> #include<stdlib.h> #include<math.h> #include<assert.h> #include<string.h> #define POINTS 1000 struct point{ double x; double y; }; #include"quickSortClosestPair.c" double gaussrand(); void generatePoints(struct point *pp[]); double closestPair(structLeave a comment:
-
Segmentation fault in determining closest pair
I'm trying to code the closest pair algorithm...but when the distribution of points is too close, it is giving segmentation fault. My algorithm is right as for points sparsely placed it is giving same answer with bruteforce...th e problem is most probably when the line dividing points into two halves contain more than one point(not sure though) whose probability inc. with more and more points in picture. Here's my code
http://pastebin.com/ZbDtC9dq... -
Problem with inbuilt sort() function in c++
Explaining doubt with example ::
I have a vector of pair say vv having values vv[0]=(9,1) vv[1]=(13,2) vv[2]=(9,3) vv[3]=(6,4) vv[4]=(9,5)
and an array 'aa' having values {5,10,1,4,3}
now using sort func., i want to sort my vector of pair such that if vv[i].first==vv[j].first then the one having larger value of aa[vv[i].second] and aa[vv[j].second] should come first otherwise normal sort.
... -
-
Just inquiring about the nature of a programming element...thnx for the reply,cleared many things....i've lil doubt in case 2. Since the goto skips the statement that initializes i then why don't it read the value of i already present i.e. i=7 ?...Leave a comment:
-
I'm not sure how goto statement works during the compiling phase...but i think it should directly jump to line 8 thus skipping the part "int i=5". Also any idea why case 2 giving 0 as output in your compiler ?...Leave a comment:
-
Problem with "goto" in c
output == 5Code:#include<stdio.h> int main() { int i=7; goto x; if(1){ static int i=5; x: printf("%d",i); } return 0; }
...Code:#include<stdio.h> int main() { int i=7; goto x; if(1){ int i=5; x: printf("%d",i);
No activity results to display
Show More
Leave a comment: