User Profile

Collapse

Profile Sidebar

Collapse
noob15
noob15
Last Activity: Aug 31 '10, 09:52 PM
Joined: Jun 1 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • noob15
    replied to char * in array of int
    in C
    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 ??...
    See more | Go to post

    Leave a comment:


  • noob15
    started a topic char * in array of int
    in C

    char * in array of int

    Code:
    	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);
    output :: 44 1 0

    can someone help me with why this output is coming (especially 1 after 44)
    See more | Go to post
    Last edited by Banfa; Jul 31 '10, 09:04 PM. Reason: Added [code] ... [/code] tags

  • noob15
    started a topic Which programming language should i learn

    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
    See more | Go to post

  • noob15
    started a topic typecasting using pointer
    in C

    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
    See more | Go to post

  • noob15
    replied to Segmentation fault in determining closest pair
    in C
    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....
    See more | Go to post

    Leave a comment:


  • noob15
    replied to Segmentation fault in determining closest pair
    in C
    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
    ...
    See more | Go to post

    Leave a comment:


  • noob15
    replied to Segmentation fault in determining closest pair
    in C
    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(struct
    ...
    See more | Go to post

    Leave a comment:


  • noob15
    started a topic Segmentation fault in determining closest pair
    in C

    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...
    See more | Go to post

  • noob15
    started a topic Problem with inbuilt sort() function in c++
    in C

    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.

    ...
    See more | Go to post

  • noob15
    replied to Problem with "goto" in c
    in C
    Thanks Banfa and dheerajjoshim !! :)
    See more | Go to post

    Leave a comment:


  • noob15
    replied to Problem with "goto" in c
    in C
    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 ?...
    See more | Go to post

    Leave a comment:


  • noob15
    replied to Problem with "goto" in c
    in C
    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 ?...
    See more | Go to post

    Leave a comment:


  • noob15
    started a topic Problem with "goto" in c
    in C

    Problem with "goto" in c

    Code:
    #include<stdio.h>
    int main()
    {
        int i=7;
        goto x;
        if(1){
            static int i=5;
            x:   printf("%d",i);
        }
        return 0;
    }
    output == 5

    Code:
    #include<stdio.h>
    int main()
    {
        int i=7;
        goto x;
        if(1){
            int i=5;
            x:   printf("%d",i);
    ...
    See more | Go to post
No activity results to display
Show More
Working...