搜尋此網誌

[C/C++][動態變數的使用]

/*
* File Name: DynamicVariable.cpp
* Author: MH
* Since 2013/03/03
* Toolkit: Dev C++ 4.9.9.9
*/

#include <iostream>

using namespace std;

int main(){

    int *s;

    s = new int;
    cout << "intput int *s " << endl;
    cin >> *s;    // generating
    cout << "*s = " << *s << endl;

    // deallocate the memory when no longer needed
    delete s;

    return 0;
}

沒有留言:

張貼留言