TAILIEUCHUNG - C++ Lab2 Sending the output to a printfile Data Types

You are required to submit hard copies of all programs and program runs for every assignment given to you. This lab explains how to send the output to a text file which can be printed from any program (such as notepad) or directly from DOS. Suppose you created a text file called from a program, this file then can be printed by opening it under Word, WordPerfect, or any other program. | Lab2 Sending the output to a printfile Data Types You are required to submit hard copies of all programs and program runs for every assignment given to you. This lab explains how to send the output to a text file which can be printed from any program such as notepad or directly from DOS. Suppose you created a text file called from a program this file then can be printed by opening it under Word WordPerfect or any other program. You can also print it by going to DOS prompt and typing the following type prn Program OneA 1. Printing to a file By Dr. John Abraham Created for 1380 students Instructional objective create print file include iostream include fstream to handle files using namespace std int main int i j k l m n float a b c ofstream outfile output file stream handle is outfile a assign a DOS name to the handle creates a file called in floppy drive A integer operations cout INTEGER OPERATIONS n n i 6 3 l m j l m k 10 3 n 10 3 cout 6 3 i n cout l m l m j n cout 10 3 k n cout 10 3 n n outfile 6 3 i n outfile l m l m j n outfile 10 3 k n outfile 10 3 n n real and mixed operations cout nREAL AND MIXED OPERATIONS n n outfile nREAL AND MIXED OPERATIONS n n a 10 3 b c 3 cout 10 3 a n cout b n cout 3 c n outfile 10 3 a n outfile b n outfile 3 c n getchar return 0 In order to create a textfile follow these steps 1. Required preprocessor directive include fstream 2. Give a file handle such as outfile printfile textfile or anything you like. Now on the file will be referred to using this name in the program. 3. Assign this handle to an actual DOS file name. DOS file names are 8 character long a dot and 3 character extension. You may include the drive letter and path in front of the file name. For example C mydocuments cprograms printfiles 4. Place any character stream you want in this file by using the

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.