User Profile

Collapse

Profile Sidebar

Collapse
micko
micko
Last Activity: Mar 26 '07, 09:47 AM
Joined: Mar 19 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • micko
    replied to C++ Code
    in C
    It compiles, first printout is 0 and the second is some address like -84551551.
    But the program gives the same result without delete [ ] array.
    I think it is good, it is always good to use delete.
    See more | Go to post

    Leave a comment:


  • micko
    replied to C++ Code
    in C
    Dynamic allocation, using delete [ ] array?
    See more | Go to post

    Leave a comment:


  • micko
    replied to C++ Code
    in C
    I think there is a problem with the array function, it should return new array if integers.

    // CODE

    int *array (int n)
    {
    return new int(n); // should be new int[ ];
    }
    //

    Am I wrong?
    See more | Go to post

    Leave a comment:


  • micko
    replied to C++ Code
    in C
    yes, try to find problem
    See more | Go to post

    Leave a comment:


  • micko
    started a topic C++ Code
    in C

    C++ Code

    What is wrong with this code?
    Code:
    int *array (int n)
    {
    	return new int(n);
    }
    
    int main()
    {
    	int *p = array(10);
    
    	for(int i = 0; i < 10; i++)
    	{
    		p[i]= 0;	// initialize all to 0
    	}
    	
    	printf( "%d\n", p[0]);
    	p = array(10);
    	printf ("%d\n", p[0]);
    	return 0;
    }
    See more | Go to post
    Last edited by RedSon; Mar 19 '07, 10:53 PM. Reason: CODE Tags!
No activity results to display
Show More
Working...