Memory allocation. Pretty simple, but I guess there might be some people here who do not know what it is...

#include<stdio.h>
#include<iostream.h>
int main()
{
    int *n = new int;
    *n=12;
    printf("n's value is %d\n",*n);
    *n=25;
    printf("n's value is %d\n",*n);
    delete n;
    printf("n was deleted\n");
    system("PAUSE");
    return 0;
}

Recommended Answers

All 8 Replies

Are you one of them?

Are you one of them?

I don't quite get what you mean? Here is just one little example... it works as intented in my compiler. If you mean that this is too simple, then yes, you are right. If you want something more complicated, tell me and I'll try my best...

If you weren't mean, then I'm sorry.

I don't quite get what you mean? Here is just one little example... it works as intented in my compiler. If you mean that this is too simple, then yes, you are right. If you want something more complicated, tell me and I'll try my best...

If you weren't mean, then I'm sorry.

What do I mean? People generally post technical questions here. If you want to post a code snippet then you should post it that way.

Also, since this is the C forum, using C++ commands to do the work will just confuse and frustrate anyone trying your suggestions.

A for effort, F for execution.

the code is fine and will work........do you want help with the code

the code is fine and will work........do you want help with the code

The code is NOT fine. It is C++ code, not C. new and delete are C++ commands, not C, therefore, not fine!

According to language, the code is fine.
But OP should not have posted it here.
That's not my fault

commented: Fail. -3

According to language, the code is fine.

Read the C standard. there is no new nor delete command available. Period.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.