0

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;
}
4
Contributors
8
Replies
10
Views
6 Years
Discussion Span
Last Post by WaltP
0

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.

0

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.

Edited by gerard4143: n/a

0

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.

0

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!

Edited by WaltP: n/a

0

According to language, the code is fine.

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.