User Profile

Collapse

Profile Sidebar

Collapse
destination
destination
Last Activity: Oct 5 '10, 09:20 AM
Joined: Dec 7 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • destination
    started a topic time complexity of a program
    in C

    time complexity of a program

    How to find time complexity of a program and various algorithm??
    Can anyone suggest me any reading on this topic?
    See more | Go to post

  • destination
    started a topic how does a C program gets executed
    in C

    how does a C program gets executed

    I want to know how a C program gets executed. I mean what happens when we compile.
    What steps compiler follow for successful execution of a program?
    What happens at compile time and run time?
    Can u please give me any link on internet which explains these things properly.
    See more | Go to post
    Last edited by Niheel; May 5 '10, 08:11 AM. Reason: grammar, punctuation

  • destination
    replied to interchanging int and static
    in C
    The compiler didnot complain.
    I just asked it to know if this is possible there is no other reason for that.
    See more | Go to post

    Leave a comment:


  • destination
    started a topic interchanging int and static
    in C

    interchanging int and static

    static int i;
    int static i;

    Can i interchange static and int while defining a variable.
    See more | Go to post

  • destination
    replied to two pointers same address
    in C
    You mean the difference gives the number of elements between two pointers
    See more | Go to post

    Leave a comment:


  • destination
    replied to two pointers same address
    in C
    I made a mistake in asking the question

    #include <stdio.h>
    int main(void)

    {
    int a=1,*p=&a,*q=p;
    printf("%p %p",p,q);
    p++;
    printf("\n%p",p-q);
    }

    Why does this prints 1 but i expected it to print 4.
    If p initially points to 1000 and q also to 1000 after p++ p will ;point to 1004
    and when i take the difference it sud print 4 but why...
    See more | Go to post

    Leave a comment:


  • destination
    replied to two pointers same address
    in C
    #include <stdio.h>
    int main(void)

    {
    int a=1,*p=&a,*q=p;
    printf("%p %p",p,q);
    p++;
    printf("\n%p",p );

    getch();
    }
    LOok at this code snippet.
    Why does this gives 1 i thought it will print 4 on my machine as int takes 4 bytes on my machine.

    Also if i use this line
    printf("\n%p",( char*)p-(char*)q);
    it prints 4 ....
    See more | Go to post

    Leave a comment:


  • destination
    started a topic two pointers same address
    in C

    two pointers same address

    #include <stdio.h>
    int main(void)
    {
    int a=1,*p=&a,*q=p;
    printf("%p %p",p,q);
    return 0;
    }
    I have a doubt in the above code. There are two pointers p and q .when i print the address of p and q it comes out to be same. how is this possible. I know that both are pointing to same location but still they are two different variables then address corresponding to them sud also be different...
    See more | Go to post

  • destination
    replied to negative index in array
    in C
    donbock
    I read in K&R so i thought its possible to do such thing
    This is quote from K&R
    "If one is sure that the elements exist, it is also possible to index backwards in an array; p[-1], p[-2], and so on are syntactically legal, and refer to the elements that immediately precede p[0]. Of course, it is illegal to refer to objects that are not within the array bounds."
    chapter 5 (5.3 Pointers and Array)...
    See more | Go to post

    Leave a comment:


  • destination
    replied to negative index in array
    in C
    Banfa
    You said that it is not hte right way to handle negative indexes in array then what should be the right way to access a negative index.
    Take a simple example
    int a[10]={1,2,3,4,5};
    suppose i further declare a[-1]=0 and then use it in the code will that be a wrong thing to do?
    In the original question i have padded the array and then using it.Is that a wrong thing?
    See more | Go to post

    Leave a comment:


  • destination
    started a topic UB or not
    in C

    UB or not

    first code
    Code:
    char * f(void){
        char a[]="C is a very good language";
        return a;
    }
    
    int main()
    {
        char* b= f();
        printf("%s",b);
        getchar();
    }
    second code
    Code:
    int f(void){
        int x=9;
        return x;
    }
    
    int main()
    {
        int i=f();
        printf("%d",i);
        getchar();
    ...
    See more | Go to post

  • destination
    started a topic negative index in array
    in C

    negative index in array

    say i have a two dimensional array a[512][512]. There is one more 2D array
    b[512][512]. The algorithm is like this depending on value of a[i][j] i have compare b[j][k] with two of its neighbour.
    This is a part of that algorithm
    if(a[j][k]==0)
    {
    if(b[j][k]>=b[j][k+1] && b[j][k]>=b[j][k-1])
    some code here
    }

    the problem is when k=0...
    See more | Go to post

  • destination
    started a topic assignment operator and copy constructor
    in C

    assignment operator and copy constructor

    class A
    {
    public:
    A() {cout << "1";}
    A operator=(const A&){cout << "2"; return *this;}
    A (const A&) {cout << "3";}
    };
    int main()
    {
    A a1;
    A a2 = a1;//line 1
    a2 = a1;//line 2
    }

    pls explain which functions will be called in line 1 and line 2 and why??
    See more | Go to post

  • destination
    started a topic Undefined behaviour
    in C

    Undefined behaviour

    why a[i]=i++ is an UB. here the value of i has changed only once.
    also i think there is no ambiguity in the value of i because in assignment operator the RHS part is evaluated and then assigned to LHS . so why this is an UB.
    See more | Go to post

  • destination
    replied to pointer to an array
    in C
    actually i interpreted int(*p)[5] wrongly.that was the reason for that confusion.
    No confusions now .Thanx.
    See more | Go to post

    Leave a comment:


  • destination
    started a topic pointer to an array
    in C

    pointer to an array

    In general int (*p)[3] means p is a pointer to an array which stores 3 integers.
    Correct me here if i am wrong.

    look at this code
    int (*p)[3]={1,2,3};
    Is the above statement valid?If not then why.pls explain it.

    Also what will int (*p)[3] hold? i mean an int pointer or an int
    See more | Go to post

  • destination
    replied to array
    in C
    Car parking example was awesome.Really a gr8 explanation
    A big thanx to you Banfa.You are gr8.
    See more | Go to post

    Leave a comment:


  • destination
    replied to array
    in C
    Banfa
    i read ur above post and it cleared my doubt but still there are some doubts somewhere in my mind.pls answer it.

    Let us say i have int a[3]={1}
    .Its first element i.e. a[0] will be stored at some location say 23FF60.If i write &a[0] i will get this value(23FF60) again if i write a i will get the same value.
    My question is why are address of a[0] (i.e. &a[0]) and address of a(&a) are stored at the...
    See more | Go to post

    Leave a comment:


  • destination
    replied to array
    in C
    Banfa
    You mean to say address of a[0] and a are stored at the same location.
    Also what should &a+2 yield??
    See more | Go to post

    Leave a comment:


  • destination
    started a topic array
    in C

    array

    int a[10];
    why does
    printf("%p",a); and printf("%p",&a) ;
    print the same result.

    also printf("%p",&(a )); //this works fine
    but printf("%p",.&( a+2));//results into error.
    See more | Go to post
No activity results to display
Show More
Working...