Đầu vào và đầu ra Thông thường, chúng tôi muốn cung cấp đầu vào cho chương trình của chúng tôi: liệu
rằng họ có thể xử lý để sản xuất một kết quả. Cách đơn giản nhất để cung cấp dữ liệu đầu vào được
minh họa trong UseArgument (CHƯƠNG TRÌNH 1.1.2). Bất cứ khi nào UseArgument được thực thi,
nó đọc các đối số dòng lệnh mà bạn gõ sau tên chương trình và
in nó lại ra nhà ga như là một phần của thông điệp. Kết quả của việc thực hiện
chương trình này phụ thuộc vào những gì chúng tôi loại sau tên chương trình. Sau khi biên dịch
chương trình một lần, chúng ta có thể chạy nó cho các đối số dòng lệnh khác nhau và nhận được
kết quả in khác nhau. Chúng tôi sẽ thảo luận chi tiết hơn về cơ chế mà chúng tôi sử dụng
để truyền tham số cho chương trình của chúng tôi sau này, trong PHẦN 2.1. Trong khi đó, bạn có thể
sử dụng args [0] trong cơ thể của chương trình của bạn để đại diện cho chuỗi mà bạn gõ vào
dòng lệnh khi nó được thực thi, cũng giống như trong UseArgu
ment.
đang được dịch, vui lòng đợi..