Home Segments Index Top Previous Next

548: Mainline

The following is an example in which the file pointer named trade_source is declared, and that file pointer is attached to a structure, via fopen, that names "test.data" as the file to be read from:

                     File specification 
                          | 
                          v 
FILE* trade_source;   ---------     
trade_source = fopen("test.data", "r"); 
------------                       ^ 
    ^                              | 
    |                       Read specification 
File-pointer name 

Thus, the file-opening ritual involves one statement that creates a pointer and another that attaches the pointer to a file-describing structure.