[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


fwide

Determine the orientation of a stream.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdio.h>
  int fwide(FILE *stream, int orientation);
Parameters:

Parameters for this facility are:

stream  
FILE *  
A pointer to the stream being tested  
orientation  
int  
The desired orientation  

Remarks:

The fwide function determines the orientation of the stream pointed to by stream. If the value of orientation is greater than zero and stream is without orientation, stream is made to be wide oriented. If the value of orientation is less than zero and stream is without orientation, stream is made to be byte oriented. Otherwise, the value of orientation is zero and the function does not alter the orientation of the stream. In all cases, if stream already has an orientation, it will not be changed.

Return:

The fwide function returns a value greater than zero if, after the call, the stream has wide orientation, a value less than zero if the stream has byte orientation, or zero if thestream has no orientation.

Example of fwide() usage.:
#include <stdio.h>

int main()
{	
	FILE * fp;
	char filename[FILENAME_MAX];
	int orientation;
	char * cptr;
	
	cptr = tmpnam(filename);
	fp = fopen(filename, "w");
	orientation = fwide(fp, 0);
	
	// A newly opened file has no orientation
	printf("Initial orientation = %i\n", orientation);
	fprintf(fp, "abcdefghijklmnopqrstuvwxyz\n");
	
	// A byte oriented output operation will set the orientation
	// to byte oriented
	orientation = fwide(fp, 0);
	
	printf("Orientation after fprintf = %i\n", orientation);
	fclose(fp);
	fp = fopen(filename, "r");
	orientation = fwide(fp, 0);
	printf("Orientation after reopening = %i\n", orientation);
	orientation = fwide(fp, -1);
	
	// fwide with a non-zero orientation argument will set an
	// unoriented file's orientation
	printf("Orientation after fwide  = %i\n", orientation);
	orientation = fwide(fp, 1);
	
	// but will not change the file's orientation if it 
	// already has an orientation
	printf("Orientation after second fwide  = %i\n",              									orientation);
	fclose(fp);
	remove(filename);
		
	return 0;
}

Output:
Initial orientation = 0
Orientation after fprintf = -1
Orientation after reopening = 0
Orientation after fwide  = -1
Orientation after second fwide  = -1


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000