Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Windows 10 作業系統電腦 */
- #include <iostream>
- #include <cstdlib>
- using std::cout;
- using std::cin;
- int main(int argc, char *argv[]) {
- system("color f0");
- int length = 0;
- int *ptr = NULL;
- cout << "Please input array length : ";
- cin >> length;
- ptr = new int[length];
- cout << "ptr = " << ptr << "\n";
- for (int i = 0; i < length; i++) {
- *(ptr + i) = (i + 1);
- }
- for (int i = 0; i < length; i++) {
- cout << ptr[i] << ", ";
- }
- cout << "\n";
- delete[] ptr;
- ptr = NULL;
- cout << "\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement