User Profile

Collapse

Profile Sidebar

Collapse
mickey22
mickey22
Last Activity: Sep 8 '08, 12:40 PM
Joined: Feb 20 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • mickey22
    started a topic deleting an array of objects
    in C

    deleting an array of objects

    Could you please give an example how to create and an array of objects and how to delete them ?

    Do I have to create for loop to delete all of them?
    See more | Go to post

  • mickey22
    replied to debug vs release version
    in C
    Thank you for the reply.

    ptr++ in the second case increases by 40 ----- does it mean that ptr++ means it points to the last element of the array it is pointing to?
    If I want to acess some middle element how do I call through this pointer.

    For eg: a[]={1,2 ,3,4};
    int (*ptr)[4];

    if I want to print out a[2]=3 using *ptr how can i do it?
    See more | Go to post

    Leave a comment:


  • mickey22
    started a topic debug vs release version
    in C

    debug vs release version

    Hi all,

    I have some theoritical questions.

    1. Why sometimes any piece of code works fine in th debug version and fails in the release version ?

    could anyone please state the difference between relase and debug version?

    2. int *ptr[10]; //10 pointers pointing to an integer

    what happens if we do ptr++ ?What should I do if I want to acess all the pointers?

    int(*ptr)[10];...
    See more | Go to post

  • mickey22
    replied to delete operation
    in C
    Actually I have solved using the copy function memcpy and just copied the data pointed by data1 to pointer data2.Now I dont have any problem in the delete operations .

    thanks a lot .
    See more | Go to post

    Leave a comment:


  • mickey22
    replied to delete operation
    in C
    yes I have observed there is memory leak when I copy the adresses of the pointers and delete them in class A and class B.Thats where I get an error when I try to peform delete in class A.
    delete[] data2;

    How can I copy the values pointed by data2 to data1 point to the same values having data1 and data2 as different adresses so that I can delete them in both the classes?Can you suggest me the way?
    See more | Go to post

    Leave a comment:


  • mickey22
    replied to delete operation
    in C
    Hi all,

    When I initialise in this way,

    b::b(float *_data2)
    {
    data2 = new float(*_data2);
    }

    copying of the data from class A is not done properly.data2 contains some weird values.

    So I tried to do as:

    b::b(float *_data2,int _x,int _y)
    {
    x=_x;
    y=_y;
    data2=new float[x*y];
    data2=_data2;
    }

    I get a...
    See more | Go to post

    Leave a comment:


  • mickey22
    replied to delete operation
    in C
    Thank you ..using new operator solved my problem.

    One question: is it not required to initialise data2 in class B to NULL before using new operator?

    If yes can I intialise in this way :
    data2=NULL;
    data2=new float(*_data2);
    See more | Go to post

    Leave a comment:


  • mickey22
    started a topic delete operation
    in C

    delete operation

    I have created a pointer to a data in a class A and passing this pointer to a function in another class B.when I try to delete this pointer in class A I get run time exception.
    But if I dont delete the object of class B I dont get any error it runs fine.But I have to delete the object of class B.I have illustrated theexample..Cou ld anyone help with it?

    [CODE=cpp]//func2.h

    class b
    {
    private:...
    See more | Go to post
    Last edited by Ganon11; May 5 '08, 05:05 PM. Reason: Please use the [CODE] tags provided.

  • mickey22
    started a topic clearing the data in a file
    in C

    clearing the data in a file

    I have a file already written and I want to clear all the contents in it.

    code:

    int number=10;
    FILE *fp;
    fopen_s(&fp,"a. txt","a");
    /////want to clear the data here in a.txt file
    fprintf(fp,"%d" ,number);
    fclose(fp);

    after opening the file I want to clear all the contents first and then print the number in the a.txt.I...
    See more | Go to post

  • mickey22
    started a topic Displaying decimal numbers in C++
    in C

    Displaying decimal numbers in C++

    Hi all,

    I want to specify a limit of numbers to be printed after the decimal point .Could anyone tell me what to use in vc++ ?

    eg: 5.3446785

    I want to print just 5.34467

    Thanks.
    See more | Go to post

  • mickey22
    replied to Problem with the while statemnet
    in C
    I just tried in the same way writing separately..It works fine.When I include some other statements it does'nt work.Its really wierd.

    Thanks for all the suggestions.
    See more | Go to post

    Leave a comment:


  • mickey22
    started a topic Problem with the while statemnet
    in C

    Problem with the while statemnet

    I have some problem in execution of the program :

    the code is for example:

    void a (float value)
    {

    float size=0;
    size=value;
    while(size>=val ue)
    {
    some statements
    }

    when I print the values of size and value, they are the same.but it is
    not entering the while loop even though the condition is true.If I just write some
    cout statement...
    See more | Go to post

  • mickey22
    replied to delete operator in c++
    in C
    I removed NULL. It did not work.

    I have my code in this way:

    my own class

    [CODE=cpp]///abc.h

    class abc
    {
    int off;
    int *img;
    abc(void);
    ~abc( );
    void sum( );
    };

    //abc.cpp

    abc::abc(void)
    {
    off=0;
    }
    abc::~abc( )
    {
    delete[] img;
    }
    ...
    See more | Go to post
    Last edited by Ganon11; Nov 6 '07, 06:32 PM. Reason: Please use the [CODE] tags provided.

    Leave a comment:


  • mickey22
    started a topic delete operator in c++
    in C

    delete operator in c++

    Hi all,

    I have a class say A and created a pointer to call this class like

    A *obj=NULL;
    obj=new A( );

    After I perform all the operations within the code and try to delete this pointer using

    delete obj;
    obj=NULL;

    I get an exception as
    " the instruction at "0x7c910f 2b" REFERENCED MEMORY AT "0x00000004".th e memory could not be...
    See more | Go to post

  • mickey22
    replied to Calling of template function
    in C
    I just tried including the template definition inside test.h instead of in the test.cpp.I don't get any linker errors when I call in the same way using the object.
    But including the definition in the header file is not optimal solution.Is there any other way of doing this?

    Thanks
    See more | Go to post

    Leave a comment:


  • mickey22
    replied to Calling of template function
    in C
    the code I have wriiten just as an example..To clear the things, I have declared the function as public and main also I have specified as

    int main( )

    I am compiling test.cpp and main.cpp together at the same time.

    I am not able to undestand how to call my my template function in the main using the object..I have to give my template T as float.My guess is the way I am calling template function is something...
    See more | Go to post

    Leave a comment:


  • mickey22
    started a topic Calling of template function
    in C

    Calling of template function

    Hi all,

    I have a template function implemented in test.cpp.

    test.h
    [code=cpp]
    class test
    {
    template<typena me T>
    void function1( );
    }

    test.cpp
    {
    template<typena me T>
    test::function1 ( )
    {
    statements
    }

    }[/code]
    Now I have my main program

    main.cpp
    [code=cpp]
    #include"test.h "...
    See more | Go to post
    Last edited by sicarie; Aug 27 '07, 07:16 PM. Reason: Code Tags.

  • mickey22
    replied to File Append operation in c++
    in C
    The problem is that I have called ofstream("resul ts.txt",ios::ou t); in a function say function1 and I have to call this function from function2 .

    Each time I call this function1 from function2 the above statement fstream is being called and ios::out is creating new output file.

    In case if I place ios::app I am not able to clear the contents when I run the program each time.

    In what way can I...
    See more | Go to post

    Leave a comment:


  • mickey22
    replied to Application error in vc++
    in C
    It works well without any warning when I run on 32 bit machine, the 32 bit code.
    But I just tried compiling simple example like just a cout statement it works fine.
    See more | Go to post

    Leave a comment:


  • mickey22
    started a topic Application error in vc++
    in C

    Application error in vc++

    Hi all,

    I have a console application in vc++ and I wanted to generate an executable of 32 bit on 64 bit machine (windows). I dont get any compile or linking errors, but when I try to run the excutable I get the error as :

    "The application failed to initialize properly (0XC000007b).Cl ick on OK to terminate the application. "

    When i am running the same code on 32 bit machine it works fine.
    ...
    See more | Go to post
No activity results to display
Show More
Working...