#include <stdio.h>
Link against:
libc.lib
Interface status: |
externallyDefinedApi |
|
__SLBF 0x0001
Description
line buffered
Interface status: |
externallyDefinedApi |
|
__SNBF 0x0002
Description
unbuffered
Interface status: |
externallyDefinedApi |
|
__SRD 0x0004
Description
OK to read
Interface status: |
externallyDefinedApi |
|
__SWR 0x0008
Description
OK to write
Interface status: |
externallyDefinedApi |
|
__SRW 0x0010
Description
open for reading & writing
Interface status: |
externallyDefinedApi |
|
__SEOF 0x0020
Description
found EOF
Interface status: |
externallyDefinedApi |
|
__SERR 0x0040
Description
found error
Interface status: |
externallyDefinedApi |
|
__SMBF 0x0080
Description
_buf is from malloc
Interface status: |
externallyDefinedApi |
|
__SAPP 0x0100
Description
fdopen(int,const char *)
fdopen(int,const char *)
ed in append mode
Interface status: |
externallyDefinedApi |
|
__SSTR 0x0200
Description
this is an sprintf or snprintf string
Interface status: |
externallyDefinedApi |
|
__SOPT 0x0400
Description
do fseek(FILE *,long,int)
fseek(FILE *,long,int)
optimization
Interface status: |
externallyDefinedApi |
|
__SNPT 0x0800
Description
do not do fseek(FILE *,long,int)
fseek(FILE *,long,int)
optimization
Interface status: |
externallyDefinedApi |
|
__SOFF 0x1000
Description
set iff _offset is in fact correct
Interface status: |
externallyDefinedApi |
|
__SMOD 0x2000
Description
true; fgetln modified _p text
Interface status: |
externallyDefinedApi |
|
__SALC 0x4000
Description
allocate string space dynamically
Interface status: |
externallyDefinedApi |
|
__SIGN 0x8000
Description
ignore this file in _fwalk
Interface status: |
externallyDefinedApi |
|
_IOFBF 0
Description
setvbuf should set fully buffered
Interface status: |
externallyDefinedApi |
|
_IOLBF 1
Description
setvbuf should set line buffered
Interface status: |
externallyDefinedApi |
|
_IONBF 2
Description
setvbuf should set unbuffered
Interface status: |
externallyDefinedApi |
|
BUFSIZ 1024
Description
size of buffer used by setbuf
Interface status: |
externallyDefinedApi |
|
EOF (-1)
Description
End of file
Interface status: |
externallyDefinedApi |
|
FOPEN_MAX 20
Description
must be less than OPEN_MAX
Interface status: |
externallyDefinedApi |
|
FILENAME_MAX 256
Description
must be less than PATH_MAX
Interface status: |
externallyDefinedApi |
|
L_tmpnam 256
Description
must be == PATH_MAX
Interface status: |
externallyDefinedApi |
|
TMP_MAX 308915776
Description
temporary max value
Interface status: |
externallyDefinedApi |
|
stdin (__stdin())
Description
standard input variable
Interface status: |
externallyDefinedApi |
|
stdout (__stdout())
Description
standard output variable
Interface status: |
externallyDefinedApi |
|
stderr (__stderr())
Description
standard error variable
Interface status: |
externallyDefinedApi |
|
L_cuserid 17
Description
size for cuserid(3)
Interface status: |
externallyDefinedApi |
|
L_ctermid 256
Description
size for ctermid(3)
Interface status: |
externallyDefinedApi |
|
__isthreaded (*isthreaded())
Description
defined to isthreaded(void)
Interface status: |
externallyDefinedApi |
|
feof (p) (!__isthreaded ? __sfeof(p) : (feof)(p))
Description
Functions defined in ANSI C standard.
Parameters
Interface status: |
externallyDefinedApi |
|
ferror (p) (!__isthreaded ? __sferror(p) : (ferror)(p))
Description
Functions defined in ANSI C standard.
Parameters
Interface status: |
externallyDefinedApi |
|
clearerr (p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
Description
Functions defined in ANSI C standard.
Parameters
Interface status: |
externallyDefinedApi |
|
fileno (p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
Description
Functions defined in ANSI C standard.
Parameters
Interface status: |
externallyDefinedApi |
|
getc (fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
Description
Functions defined in ANSI C standard.
Parameters
Interface status: |
externallyDefinedApi |
|
getchar (void) getc(stdin)
Description
Defined to getc
Parameters
Interface status: |
externallyDefinedApi |
|
putchar (x) putc(x, stdout)
Description
defined to putc
Parameters
Interface status: |
externallyDefinedApi |
|
typedef __off_t fpos_t;
Description
Represents file position
IMPORT_C char* tmpdirname(void);
Description
Note:String that the function will return is not to be modified.
Examples:
/* Illustrates how to use tmpdirname() API */
#include <stdio.h>
int main()
{
char *ptr;
ptr=tmpdirname();
printf("%s\n",ptr);
return 0;
}
Return value
Interface status: |
externallyDefinedApi |
|
IMPORT_C void clearerr(FILE *);
Description
The function clearerr clears the end-of-file and error indicators for the stream pointed to by fp.
The function feof tests the end-of-file indicator for the stream pointed to by fp, returning non-zero if it is set. The end-of-file
indicator can only be cleared by the function clearerr.
The function ferror tests the error indicator for the stream pointed to by fp, returning non-zero if it is set. The error
indicator can only be reset by the clearerr function.
The function fileno examines the argument fp and returns its integer descriptor.
Examples:
/* this program shows finding error set using ferror
and clearing it using clearerr functions */
# 26 "d:/EPOC/release/9.4/common/generic/openenv/core/include/stdio.dosc" 2
int main()
{
char a;
FILE* fp = fopen("c:\input.txt", "w");
fprintf(fp, "%s", "abcdefghijklmn");
fprintf(fp, "%c", '
');
fprintf(fp, "%s", "fdsfdsafsdabcdefghijklmn");
fclose(fp);
fp=fopen("c:\input.txt","r");
if (fp == 0 )
{
printf("fopen failed");
return -1;
}
else
{
fwrite(&a;, sizeof(char), 1, fp);
if ((! (*isthreaded()) ? ((( fp )->_flags & 0x0040 ) != 0) : (ferror)( fp )))
printf("error set in file stream");
else
{
fclose(fp);
return -1;
}
(! (*isthreaded()) ? ((void)(( fp )->_flags &= ~( 0x0040 | 0x0020 ))) : (clearerr)( fp ));
if (!(! (*isthreaded()) ? ((( fp )->_flags & 0x0040 ) != 0) : (ferror)( fp )))
printf("error cleared in file stream");
else printf("error still unexpected set in file stream");
fclose (fp);
}
return 0;
}
Output
error set in file stream
error cleared in file stream
Parameters
__sFILE __sFILE * |
Note: This description also covers the following functions - feof ferror fileno
|
|
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fclose(FILE *);
Description
The fclose function dissociates the named stream from its underlying file or set of functions. If the stream was being used
for output any buffered data is written first using fflush .
Examples:
/* this program shows opening and closing of a file using fclose api */
# 89 "d:/EPOC/release/9.4/common/generic/openenv/core/include/stdio.dosc" 2
int main()
{
FILE *fp;
fp = fopen("c:\input.txt", "w+");
if(fp == 0 )
{
printf("file opening failed");
return -1;
}
printf("file opened successfully: Perform file operations now
");
if(!fclose(fp))
{
printf("file closed successfully");
return 0;
}
else
{
printf("file closing failed");
return -1;
}
}
Output
file opened successfully: Perform file operations now
file closed successfully
Notes:
The fclose function does not handle 0 arguments; they will result in a segmentation violation. This is intentional - it makes
it easier to make sure programs written under are bug free. This behaviour is an implementation detail and programs should
not rely upon it.
Parameters
Return value
int |
Upon successful completion 0 is returned. Otherwise, EOF is returned and the global variable errno is set to indicate the
error. In either case no further access to the stream is possible.
|
|
Interface status: |
externallyDefinedApi |
|
IMPORT_C int feof(FILE *);
Description
Parameters
Return value
Interface status: |
externallyDefinedApi |
|
IMPORT_C int ferror(FILE *);
Description
Parameters
Return value
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fflush(FILE *);
Description
The function fflush forces a write of all buffered data for the given output or update fp via the stream's underlying write
function. The open status of the stream is unaffected.
If the fp argument is NULL, fflush flushes all open output streams.
Examples:
/* this program shows flushing user space buffered data using fflush */
# 178 "d:/EPOC/release/9.4/common/generic/openenv/core/include/stdio.dosc" 2
int main()
{
FILE *fp;
int retval = 0;
char name[20] = "c:\flush1.txt";
fp = fopen(name, "w+");
if(fp == 0 )
{
printf("Error : File open");
return -1;
}
setvbuf(fp, 0 , 0 , 100); // set to full buffering with NULL buffer
fprintf(fp, "we are trying to buffer 100 characters at once with NULL buffer.");
retval = fflush(fp);
if (retval)
{
printf("fflush failed");
fclose(fp);
unlink(name);
return -1;
}
else printf("Buffer successfully flushed");
fclose(fp);
unlink(name);
return 0;
}
Output
we are trying to buffer 100 characters at once with 0 buffer.
Buffer successfully flushed
Parameters
Return value
int |
Upon successful completion 0 is returned. Otherwise, EOF is returned and the global variable errno is set to indicate the
error.
|
|
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fgetc(FILE *);
Description
The fgetc function obtains the next input character (if present) from the stream pointed at by stream, or the next character
pushed back on the stream via ungetc.
The getc function acts essentially identically to fgetc, but is a macro that expands in-line.
The getchar function is equivalent to getc (stdin.);
The getw function obtains the next int (if present) from the stream pointed at by stream.
The getc_unlocked and getchar_unlocked functions are equivalent to getc and getchar respectively, except that the caller is
responsible for locking the stream with flockfile before calling them. These functions may be used to avoid the overhead of
locking the stream for each character, and to avoid input being dispersed among multiple threads reading from the same stream.
Examples:
/* this program shows reading from file using getc */
/* consider input.txt has the following content: */
/* hi */
# 265 "d:/EPOC/release/9.4/common/generic/openenv/core/include/stdio.dosc" 2
int main(void)
{
int retval;
FILE* fp = fopen("c:\input.txt", "w");
fprintf(fp, "%s", "abcdefghijklmn");
fprintf(fp, "%c", '\n');
fprintf(fp, "%s", "fdsfdsafsdabcdefghijklmn");
fclose(fp);
fp = fopen("C:\input.txt","r");
if(fp == 0 )
{
printf("fopen failed
");
return -1;
}
while((int)(retval = (! (*isthreaded()) ? (--( fp )->_r < 0 ? __srget( fp ) : (int)(*( fp )->_p++)) : (getc)( fp )) )!= (-1) )
{
printf("%c", retval);
}
fclose(fp);
return 0;
}
Output
hi
Parameters
Return value
int |
If successful, these routines return the next requested object from the stream. Character values are returned as an unsigned
char converted to an int. If the stream is at end-of-file or a read error occurs, the routines return EOF. The routines and
ferror must be used to distinguish between end-of-file and error. If an error occurs, the global variable errno is set to
indicate the error. The end-of-file condition is remembered, even on a terminal, and all subsequent attempts to read will
return EOF until the condition is cleared with
|
|
See also:
ferror(FILE *)
ferror(FILE *)
Check for errors.
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
ungetc(int,FILE *)
ungetc(int,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fgetpos(FILE *, fpos_t *);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C char* fgets(char *, int, FILE *);
Description
The fgets function reads at most one less than the number of characters specified by n from the given stream and stores them
in the string buf. Reading stops when a newline character is found, at end-of-file or error. The newline, if any, is retained.
If any characters are read, and there is no error, a \0 character is appended to end the string.
The gets function is equivalent to fgets with an infinite size and a stream of stdin, except that the newline character (if
any) is not stored in the string. It is the caller's responsibility to ensure that the input line,if any, is sufficiently
short to fit in the string.
Examples:
/* this program shows reading characters from a file using fgets */
/* consider input.txt has the following content: */
/* abcdefghijklmn */
/* fdsfdsafsdabcdefghijklmn */
# 349 "d:/EPOC/release/9.4/common/generic/openenv/core/include/stdio.dosc" 2
int main(void)
{
char buf[20];
FILE* fp = fopen("c:\input.txt", "w");
fprintf(fp, "%s", "abcdefghijklmn");
fprintf(fp, "%c", "
");
fprintf(fp, "%s", "fdsfdsafsdabcdefghijklmn");
fclose(fp);
fp = fopen("C:\input.txt","r");
if(fp == 0 )
{
printf("fopen failed");
return -1;
}
if(fgets(buf,18,fp) != 0 )
printf("%s", buf);
else
printf("Buffer is empty");
buf[0] = '\0';
if(fgets(buf,2,fp) != 0 )
printf("%s", buf);
else
printf("Buffer is empty");
fclose(fp);
return 0;
}
Output
abcdefghijklmn
fdsfdsafsdabcdefghijklmn
Security considerations:
The gets function cannot be used securely. Because of its lack of bounds checking,and the inability for the calling program
to reliably determine the length of the next incoming line,the use of this function enables malicious users to arbitrarily
change a running program's functionality through a buffer overflow attack. It is strongly suggested that the fgets function
be used in all cases.
Parameters
Return value
char * |
Upon successful completion fgets and gets return a pointer to the string. If end-of-file occurs before any characters are
read they return NULL and the buffer contents remain unchanged. If an error occurs they return NULL and the buffer contents
are indeterminate. The fgets and gets functions do not distinguish between end-of-file and error and callers must use feof
and ferror to determine which occurred.
|
|
See also:
fopen(const char *,const char *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C FILE* fopen(const char *, const char *);
Description
The fopen function opens the file whose name is the string pointed to by file and associates a stream with it.
The argument mode points to a string beginning with one of the following sequences (Additional characters may follow these
sequences.):
"r" Open text file for reading. The stream is positioned at the beginning of the file.
"r+" Open for reading and writing. The stream is positioned at the beginning of the file.
"w" Truncate to zero length or create text file for writing. The stream is positioned at the beginning of the file.
"w+" Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file.
"a" Open for writing. The file is created if it does not exist. The stream is positioned at the end of the file. Subsequent writes to the file will always end up at the then current end of file, irrespective of any intervening fseek or similar.
"a+" Open for reading and writing. The file is created if it does not exist. The stream is positioned at the end of the file. Subsequent writes to the file will always end up at the then current end of file, irrespective of any intervening fseek or similar.
The mode string can also include the letter "b" either as a third character or as a character between the characters in any
of the two-character strings described above. This is strictly for compatibility with -isoC and has no effect; the "b" is
ignored.
Reads and writes may be intermixed on read/write streams in any order, and do not require an intermediate seek as in previous
versions of stdio. This is not portable to other systems, however; ANSI C requires that a file positioning function intervene
between output and input, unless an input operation encounters end-of-file.
The fdopen function associates a stream with the existing file descriptor, fildes. The mode of the stream must be compatible
with the mode of the file descriptor. When the stream is closed via fclose, fildes is closed also.
The freopen function opens the file whose name is the string pointed to by path and associates the stream pointed to by stream
with it. The original stream (if it exists) is closed. The mode argument is used just as in the fopen function.
If the file argument is NULL, freopen attempts to re-open the file associated with stream with a new mode. The new mode must
be compatible with the mode that the stream was originally opened with:
Streams originally opened with mode "r" can only be reopened with that same mode.
Streams originally opened with mode "a" can be reopened with the same mode, or mode "w."
Streams originally opened with mode "w" can be reopened with the same mode, or mode "a."
Streams originally opened with mode "r+," "w+," or "a+" can be reopened with any mode.
The primary use of the freopen function is to change the file associated with a standard text stream (stderr, stdin, or stdout).
Examples:
/* this program shows opening in write mode,write data and close */
/* again open in append mode and write data */
/* Check file c:\fopen.txt */
# 451 "d:/EPOC/release/9.4/common/generic/openenv/core/include/stdio.dosc" 2
int main(void)
{
FILE *fp;
char name[20] = "c:\fopen1.txt";
if ((fp = fopen (name, "w")) == 0 )
{
printf("Error creating file");
return -1;
}
printf("Opened file");
fprintf(fp, "This is the first line");
printf("Wrote to file");
fclose (fp);
printf("Closed file");
if ((fp = fopen (name, "a")) == 0 )
{
printf("Error opening file");
return -1;
}
printf("Opened file for appending");
fprintf(fp, "This is the second line");
fclose (fp);
printf("closed file, check output in c:\ fopen.txt file");
unlink(name);
return 0;
}
Output
Opened file
Wrote to file
Closed file
Opened file for appending
closed file, check output in c:\fopen.txt file
Notes:
-
Mode values for group and others are be ignored.
-
The execute bit and setuid on exec bit are ignored.
-
The default working directory of a process is initialized to C:\private\UID (UID of the calling application) and any data
written into this directory persists between phone resets.
-
If the specified file is a symbolic link and the file it is pointing to is invalid the symbolic link file will be automatically
removed.
Limitations:
A file in cannot be created with write-only permission and attempting to create one will result in a file with read-write
permission. Creating a new file with the O_CREAT flag does not alter the time stamp of its parent directory. The newly created
entry has only two time stamps: access and modification. Creation time stamp is not supported and access time stamp is initially
equal to modification time stamp. open, fclose and fflush.
KErrNotReady of symbian error code is mapped to 2 , which typically means drive not found or filesystem not mounted on the
drive.
Parameters
Return value
__sFILE __sFILE *
|
Upon successful completion fopen, fdopen and freopen return a FILE pointer. Otherwise, NULL is returned and the global variable
errno is set to indicate the error.
|
|
See also:
fprintf(FILE *,const char *,...)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fprintf(FILE *, const char *,...);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fputc(int, FILE *);
Description
The fputc function writes the character c (converted to an "unsigned char") to the output stream pointed to by fp.
The putc macro that is identically to fputc, but is a macro that expands in-line. It may evaluate stream more than once, so
arguments given to putc should not be expressions with potential side effects.
The putchar function is identical to putc with an output stream of stdout.
The putw function writes the specified int to the named output stream.
The putc_unlocked and putchar_unlocked functions are equivalent to putc and putchar respectively, except that the caller is
responsible for locking the stream with flockfile before calling them. These functions may be used to avoid the overhead of
locking the stream for each character, and to avoid output being interspersed from multiple threads writing to the same stream.
Examples:
#include <stdio.h>
int main()
{
FILE * fp;
fp=fopen("C:\input.txt","w+");
if(fp==NULL)
{
printf("file opening failed");
return -1;
}
if(putc('a',fp)!='a')
{
printf("putc failed");
fclose(fp);
return -1;
}
else printf("character successfully put by putc");
fclose(fp);
return 0;
}
Output
character successfully put by putc
Parameters
Return value
int |
The functions, fputc, putc, putchar, putc_unlocked, and putchar_unlocked return the character written. If an error occurs,
the value EOF is returned. The putw function returns 0 on success; EOF is returned if a write error occurs, or if an attempt
is made to write to a read-only stream.
|
|
See also:
fputs(const char *,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fputs(const char *, FILE *);
Description
The function fputs writes the string pointed to by s to the stream pointed to by fp.
The function puts writes the string s, and a terminating newline character, to the stream stdout.
Examples:
/*this program shows writing characters from a file using fputs */
/* consider input.txt has the following content: */
/* hello world */
# 632 "d:/EPOC/release/9.4/common/generic/openenv/core/include/stdio.dosc" 2
int main(void)
{
int wretval;
char rs1[50],rs2[50];
char *rptr;
int retval;
FILE* fp = fopen("c:\input.txt", "w");
fprintf(fp, "%s", "abcdefghijklmn");
fprintf(fp, "%c", "");
fprintf(fp, "%s", "fdsfdsafsdabcdefghijklmn");
fclose(fp);
fp = fopen("c:\input.txt","r");
if(fp == 0 )
{
printf("fopen failed");
return -1;
}
rptr = fgets(rs1,12,fp);
if(rptr == 0 )
{
printf("fgets failed");
fclose(fp);
return -1;
}
fclose(fp);
fp = fopen("c:\puts1.txt","w+");
if(fp == 0 )
{
printf("fopen failed");
return -1;
}
wretval = fputs(rs1,fp);
if(wretval == (-1) )
{
printf("fputs failed");
fclose(fp);
return -1;
}
fclose(fp);
fp = fopen("C:\puts1.txt","r");
if(fp == 0 )
{
printf("fopen failed");
return -1;
}
rptr = fgets(rs2,12,fp);
if(rptr == 0 )
{
printf("fgets failed");
fclose(fp);
return -1;
}
printf("file reading returned \"%s\",rs2);
fclose(fp);
unlink("C:\puts1.txt");
return 0;
}
Output
file reading returned "abcdefghijk"
Parameters
Return value
int |
The fputs function returns 0 on success and EOF on error. The puts function returns a nonnegative integer on success and EOF
on error.
|
|
fread(void *,size_t,size_t,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C size_t fread(void *, size_t, size_t, FILE *);
Description
The function fread reads count objects, each size bytes long, from the stream pointed to by fp, storing them at the location
given by buf.
The function fwrite writes count objects, each size bytes long, to the stream pointed to by fp, obtaining them from the location
given by buf.
Examples:
/* this program shows reading characters from a file using fread */
/* consider input.txt has the following content: */
/* hi */
#include <stdio.h>
int main()
{
char a;
FILE* fp = fopen("c:\input.txt", "w");
fprintf(fp, "%s", "abcdefghijklmn");
fprintf(fp, "%c", '\n');
fprintf(fp, "%s", "fdsfdsafsdabcdefghijklmn");
fclose(fp);
fp = fopen("c:\input.txt", "r");
if (fp == NULL)
{
printf ("fopen failed");
return -1;
}
// read single chars at a time, stopping on EOF or error:
while (fread(&a;, sizeof(char), 1, fp), !feof(fp) && !ferror(fp))
{
printf("I read \"%c\",a);
}
if (ferror(fp)) //Some error occurred
{
fclose(fp);
return -1;
}
fclose(fp);
return 0;
}
Output
I read "h"
I read "i"
Parameters
Return value
size_t size_t
|
The functions fread and fwrite advance the file position indicator for the stream by the number of bytes read or written.
They return the number of objects read or written. If an error occurs, or the end-of-file is reached, the return value is
a short object count (or zero). The function fread does not distinguish between end-of-file and error. Callers must use feof
and ferror to determine which occurred. The function fwrite returns a value less than count only if a write error has occurred.
|
|
freopen(const char *,const char *,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C FILE* freopen(const char *, const char *, FILE *);
Description
Parameters
Return value
See also:
fscanf(FILE *,const char *,...)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fscanf(FILE *, const char *,...);
Description
Parameters
Return value
See also:
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
...
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
strtod(const char *,char **)
strtod(const char *,char **)
Convert string to double-precision floating-point value. Parses string interpret...
strtol(const char *,char **,int)
strtol(const char *,char **,int)
Convert string to long integer.
strtoul(const char *,char **,int)
strtoul(const char *,char **,int)
Convert string to unsigned long integer. Parses string interpreting its content ...
wscanf(const wchar_t *,...)
wscanf(const wchar_t *,...)
...
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fseek(FILE *, long, int);
Description
The fseek function sets the file position indicator for the stream pointed to by fp. The new position, measured in bytes,
is obtained by adding offset bytes to the position specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END,
the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively. A successful
call to the fseek function clears the end-of-file indicator for the stream and undoes any effects of the ungetc and ungetwc
functions on the same stream. The fseek function call does not allows the file offset to be set beyond the end of the existing
end-of-file of the file.
The ftell function obtains the current value of the file position indicator for the stream pointed to by fp.
The rewind function sets the file position indicator for the stream pointed to by fp to the beginning of the file. It is equivalent
to:
(void)fseek(fp, 0L, SEEK_SET)
except that the error indicator for the stream is also cleared. Since rewind does not return a value, an application wishing
to detect errors should clear errno, then call rewind, and if errno is non-zero, assume an error has occurred. The fgetpos
and fsetpos functions are alternate interfaces for retrieving and setting the current position in the file, similar to ftell
and fseek, except that the current position is stored in an opaque object of type fpos_t pointed to by pos. These functions
provide a portable way to seek to offsets larger than those that can be represented by a long int. They may also store additional
state information in the fpos_t object to facilitate seeking within files containing multibyte characters with state-dependent
encodings. Although fpos_t has traditionally been an integral type, applications cannot assume that it is; in particular,
they must not perform arithmetic on objects of this type. If the stream is a wide character stream, the position specified
by the combination of offset and whence must contain the first byte of a multibyte sequence.
Examples:
/* this program shows setting file offset using fseek */
#include <stdio.h>
int main(void)
{
int retval;
FILE* fp = fopen("c:\input.txt", "w");
fprintf(fp, "%s", "abcdefghijklmn");
fprintf(fp, "%c", '');
fprintf(fp, "%s", "fdsfdsafsdabcdefghijklmn");
fclose(fp);
fp = fopen("c:\input.txt", "r");
if (fp == NULL)
{
printf ("fopen failed");
return -1;
}
retval = fseek(fp, 3, SEEK_SET); // seek to the 20th byte of the file
if (retval)
{
printf ("fseek failed");
return -1;
}
long pos = ftell(fp);
if (pos ==3)
{
printf("offset setting proper");
}
fclose(fp);
return 0;
}
Output
offset setting proper
Parameters
Return value
int |
The rewind function returns no value. Upon successful completion ftell returns the current offset. Otherwise -1 is returned
and the global variable errno is set to indicate the error.
|
|
See also:
fsetpos(FILE *,const fpos_t *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fsetpos(FILE *, const fpos_t *);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C long ftell(FILE *);
Description
Parameters
Return value
See also:
fwrite(const void *,size_t,size_t,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C size_t fwrite(const void *, size_t, size_t, FILE *);
Description
Parameters
Return value
Interface status: |
externallyDefinedApi |
|
IMPORT_C int getc(FILE *);
Description
Parameters
Return value
See also:
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
ungetc(int,FILE *)
ungetc(int,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C char* gets(char *);
Description
Parameters
Return value
Interface status: |
externallyDefinedApi |
|
IMPORT_C void perror(const char *);
Description
The strerror , strerror_r and perror functions look up the error message string corresponding to an error number.
The strerror function accepts an error number argument errnum and returns a pointer to the corresponding message string.
The strerror_r function renders the same result into strerrbuf for a maximum of buflen characters and returns 0 upon success.
The perror function finds the error message corresponding to the current value of the global variable errno and writes it,
followed by a newline, to the standard error file descriptor. If the argument string is non- NULL and does not point to the
null character, this string is prepended to the message string and separated from it by a colon and space (": "); otherwise,
only the error message string is printed.
If the error number is not recognized, these functions return an error message string containing "Unknown error: " followed
by the error number in decimal. The strerror and strerror_r functions return EINVAL as a warning. Error numbers recognized
by this implementation fall in the range 0 < errnum < sys_nerr .
If insufficient storage is provided in strerrbuf (as specified in buflen ) to contain the error string, strerror_r returns
ERANGE and strerrbuf will contain an error message that has been truncated and NUL terminated to fit the length specified
by buflen .
The message strings can be accessed directly using the external array sys_errlist . The external value sys_nerr contains a
count of the messages in sys_errlist . The use of these variables is deprecated; strerror or strerror_r should be used instead.
Examples:
#include <string.h>
#include <stdio.h>
#include <errno.h>
int main()
{
char *ptr = strerror(ERANGE);
printf("strerror( 34 ) = %s",ptr);
return 0;
}
Output
strerror(ERANGE) = Numerical result out of range
Bugs:
For unknown error numbers, the strerror function will return its result in a static buffer which may be overwritten by subsequent
calls. The return type for strerror is missing a type-qualifier; it should actually be const char * . Programs that use the
deprecated sys_errlist variable often fail to compile because they declare it inconsistently.
Parameters
Interface status: |
externallyDefinedApi |
|
IMPORT_C int printf(const char *,...);
Description
The printf family of functions produces output according to a format as described below. The printf and vprintf functions
write output to stdout, the standard output stream; fprintf and vfprintf write output to the given output stream; sprintf,
snprintf, vsprintf, and vsnprintf write to the character string str; and asprintf and vasprintf dynamically allocate a new
string with malloc.
These functions write the output under the control of a format string that specifies how subsequent arguments (or arguments
accessed via the variable-length argument facilities of stdarg ) are converted for output.
These functions return the number of characters printed (not including the trailing '\0' used to end output to strings) or
a negative value if an output error occurs, except for snprintf and vsnprintf, which return the number of characters that
would have been printed if the size were unlimited (again, not including the final '\0').
The asprintf and vasprintf functions set *ret to be a pointer to a buffer sufficiently large to hold the formatted string.
This pointer should be passed to free to release the allocated storage when it is no longer needed. If sufficient space cannot
be allocated, asprintf and vasprintf will return -1 and set ret to be a NULL pointer.
The snprintf and vsnprintf functions will write at most size -1 of the characters printed into the output string (the size'th
character then gets the terminating '\0' );if the return value is greater than or equal to the size argument, the string was
too short and some of the printed characters were discarded. The output is always null-terminated.
The sprintf and vsprintf functions effectively assume an infinite size.
The format string is composed of zero or more directives: ordinary characters (not % ), which are copied unchanged to the output stream; and conversion specifications, each of which results in fetching zero or more subsequent arguments. Each conversion specification is introduced by the % character. The arguments must correspond properly (after type promotion) with the conversion specifier. After the %, the following appear in sequence:
An optional field, consisting of a decimal digit string followed by a $, specifying the next argument to access. If this field is not provided, the argument following the last argument accessed will be used. Arguments are numbered starting at 1. If unaccessed arguments in the format string are interspersed with ones that are accessed the results will be indeterminate.
Zero or more of the following flags:
'#' The value should be converted to an "alternate form." For c, d, i, n, p, s, and u conversions, this option has no effect. For o conversions, the precision of the number is increased to force the first character of the output string to a zero (except if a zero value is printed with an explicit precision of zero). For x and X conversions, a non-zero result has the string '0x' (or '0X' for X conversions) prepended to it. For a, A, e, E, f, F, g, and G conversions, the result will always contain a decimal point, even if no digits follow it (normally, a decimal point appears in the results of those conversions only if a digit follows). For g and G conversions, trailing zeros are not removed from the result as they would otherwise be.
'0(zero)' Zero padding. For all conversions except n, the converted value is padded on the left with zeros rather than blanks. If a precision is given with a numeric conversion (d, i, o, u, i, x, and X), the 0 flag is ignored.
'-' A negative field width flag; the converted value is to be left adjusted on the field boundary. Except for n conversions, the converted value is padded on the right with blanks, rather than on the left with blanks or zeros. A - overrides a 0 if both are given.
' (space)' A blank should be left before a positive number produced by a signed conversion (a, A, d, e, E, f, F, g, G, or i).
'+' A sign must always be placed before a number produced by a signed conversion. A + overrides a space if both are used.
''' Decimal conversions (d, u, or i) or the integral portion of a floating point conversion (f or F) should be grouped and separated by thousands using the non-monetary separator returned by localeconv.
An optional decimal digit string specifying a minimum field width. If the converted value has fewer characters than the field width, it will be padded with spaces on the left (or right, if the left-adjustment flag has been given) to fill out the field width.
An optional precision, in the form of a period . followed by an optional digit string. If the digit string is omitted, the precision is taken as zero. This gives the minimum number of digits to appear for d, i, o, u, x, and X conversions, the number of digits to appear after the decimal-point for a, A, e, E, f, and F conversions, the maximum number of significant digits for g and G conversions, or the maximum number of characters to be printed from a string for s conversions.
An optional length modifier, that specifies the size of the argument. The following length modifiers are valid for the d, i, n, o, u, x, or X conversion:
Modifier d, i o, u, x, X n
hh signed char unsigned char signed char *
h short unsigned short short *
l (ell) long unsigned long long *
ll (ell ell) long long unsigned long long long long *
j intmax_t uintmax_t intmax_t *
t ptrdiff_t (see note) ptrdiff_t *
z (see note) size_t (see note)
q (deprecated) quad_t u_quad_t quad_t *
Note: the t modifier, when applied to a o, u, x, or X conversion, indicates that the argument is of an unsigned type equivalent in size to a ptrdiff_t. The z modifier, when applied to a d or i conversion, indicates that the argument is of a signed type equivalent in size to a size_t. Similarly, when applied to an n conversion, it indicates that the argument is a pointer to a signed type equivalent in size to a size_t.
The following length modifier is valid for the a, A, e, E, f, F, g, or G conversion:
Modifier a, A, e, E, f, F, g, G
l (ell) double (ignored, same behavior as without it)
L long double
The following length modifier is valid for the c or s conversion:
Modifier c s
l (ell) wint_t wchar_t *
A character that specifies the type of conversion to be applied.
A field width or precision, or both, may be indicated by an asterisk '*' or an asterisk followed by one or more decimal digits and a '\$' instead of a digit string. In this case, an int argument supplies the field width or precision. A negative field width is treated as a left adjustment flag followed by a positive field width; a negative precision is treated as though it were missing. If a single format directive mixes positional (nn$) and non-positional arguments, the results are undefined.
The conversion specifiers and their meanings are:
diouxX
The int (or appropriate variant) argument is converted to signed decimal (d and i), unsigned octal (o,) unsigned decimal (u,) or unsigned hexadecimal (x and X) notation. The letters "abcdef" are used for x conversions; the letters "ABCDEF" are used for X conversions. The precision, if any, gives the minimum number of digits that must appear; if the converted value requires fewer digits, it is padded on the left with zeros.
DOU The long int argument is converted to signed decimal, unsigned octal, or unsigned decimal, as if the format had been ld, lo, or lu respectively. These conversion characters are deprecated, and will eventually disappear.
eE The double argument is rounded and converted in the style [-d . ddd e \*[Pm] dd] where there is one digit before the decimal-point character and the number of digits after it is equal to the precision; if the precision is missing, it is taken as 6; if the precision is zero, no decimal-point character appears. An E conversion uses the letter 'E' (rather than 'e') to introduce the exponent. The exponent always contains at least two digits; if the value is zero, the exponent is 00.
For a, A, e, E, f, F, g, and G conversions, positive and negative infinity are represented as inf and -inf respectively when using the lowercase conversion character, and INF and -INF respectively when using the uppercase conversion character. Similarly, NaN is represented as nan when using the lowercase conversion, and NAN when using the uppercase conversion.
fF The double argument is rounded and converted to decimal notation in the style [-ddd . ddd,] where the number of digits after the decimal-point character is equal to the precision specification. If the precision is missing, it is taken as 6; if the precision is explicitly zero, no decimal-point character appears. If a decimal point appears, at least one digit appears before it.
gG The double argument is converted in style f or e (or F or E for G conversions). The precision specifies the number of significant digits. If the precision is missing, 6 digits are given; if the precision is zero, it is treated as 1. Style e is used if the exponent from its conversion is less than -4 or greater than or equal to the precision. Trailing zeros are removed from the fractional part of the result; a decimal point appears only if it is followed by at least one digit.
aA The double argument is rounded and converted to hexadecimal notation in the style [-0x h . hhhp[\*[Pm]d,]] where the number of digits after the hexadecimal-point character is equal to the precision specification. If the precision is missing, it is taken as enough to represent the floating-point number exactly, and no rounding occurs. If the precision is zero, no hexadecimal-point character appears. The p is a literal character 'p' and the exponent consists of a positive or negative sign followed by a decimal number representing an exponent of 2. The A conversion uses the prefix "0X" (rather than "0x"), the letters "ABCDEF" (rather than "abcdef)" to represent the hex digits, and the letter 'P' (rather than 'p') to separate the mantissa and exponent.
Note that there may be multiple valid ways to represent floating-point numbers in this hexadecimal format. For example, 0x3.24p+0, 0x6.48p-1 and 0xc.9p-2 are all equivalent. The format chosen depends on the internal representation of the number, but the implementation guarantees that the length of the mantissa will be minimized. Zeroes are always represented with a mantissa of 0 (preceded by a '-' if appropriate) and an exponent of +0.
C Treated as c with the l (ell) modifier.
c The int argument is converted to an unsigned char , and the resulting character is written.
If the l (ell) modifier is used, the wint_t argument shall be converted to a wchar_t, and the (potentially multi-byte) sequence representing the single wide character is written, including any shift sequences. If a shift sequence is used, the shift state is also restored to the original state after the character.
S Treated as s with the l (ell) modifier.
s The char * argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to (but not including) a terminating NUL character; if a precision is specified, no more than the number specified are written. If a precision is given, no null character need be present; if the precision is not specified, or is greater than the size of the array, the array must contain a terminating NUL character.
If the l (ell) modifier is used, the wchar_t * argument is expected to be a pointer to an array of wide characters (pointer to a wide string). For each wide character in the string, the (potentially multi-byte) sequence representing the wide character is written, including any shift sequences. If any shift sequence is used, the shift state is also restored to the original state after the string. Wide characters from the array are written up to (but not including) a terminating wide NUL character; if a precision is specified, no more than the number of bytes specified are written (including shift sequences). Partial characters are never written. If a precision is given, no null character need be present; if the precision is not specified, or is greater than the number of bytes required to render the multibyte representation of the string, the array must contain a terminating wide NUL character.
p The void * pointer argument is printed in hexadecimal (as if by '%#x' or '%#lx' ).
n The number of characters written so far is stored into the integer indicated by the int * (or variant) pointer argument. No argument is converted.
% A '%' is written. No argument is converted. The complete conversion specification is '%%'.
The decimal point character is defined in the program's locale (category LC_NUMERIC ).
In no case does a non-existent or small field width cause truncation of a numeric field; if the result of a conversion is
wider than the field width, the field is expanded to contain the conversion result.
Examples:
To print a date and time in the form "Sunday, July 3, 10:02", where weekday and month are pointers to strings:
#include <stdio.h>
fprintf(stdout, "%s, %s %d, %.2d:%.2d
",
weekday, month, day, hour, min);
To print pi to five decimal places:
#include <math.h>
#include <stdio.h>
fprintf(stdout, "pi = %.5f
", 4 * atan(1.0));
To allocate a 128 byte string and print into it:
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
char *newfmt(const char *fmt, ...)
{
char *p;
va_list ap;
if ((p = malloc(128)) == NULL)
return (NULL);
va_start(ap, fmt);
(void) vsnprintf(p, 128, fmt, ap);
va_end(ap);
return (p);
}
/* this program shows printing onto the console using printf */
#include <stdio.h>
int main(void)
{
char * msg="hello world";
printf("%s",msg);
return 0;
}
Output
hello world
/* this program shows reading from console using scanf */
#include <stdio.h>
int main(void)
{
char msg[100];
printf("enter message to be printed");
scanf("%s",msg);
printf("message entered is: %s",msg);
return 0;
}
Output
enter message to be printed
hello (assuming this is user input)
message entered is: hello
Security considerations:
The sprintf and vsprintf functions are easily misused in a manner which enables malicious users to arbitrarily change a running
program's functionality through a buffer overflow attack. Because sprintf and vsprintf assume an infinitely long string, callers
must be careful not to overflow the actual space; this is often hard to assure. For safety, programmers should use the snprintf
interface instead.
The printf and sprintf family of functions are also easily misused in a manner allowing malicious users to arbitrarily change
a running program's functionality by either causing the program to print potentially sensitive data "left on the stack", or
causing it to generate a memory fault or bus error by dereferencing an invalid pointer. %n can be used to write arbitrary
data to potentially carefully-selected addresses. Programmers are therefore strongly advised to never pass untrusted strings
as the format argument, as an attacker can put format specifiers in the string to mangle your stack, leading to a possible
security hole. This holds true even if the string was built using a function like snprintf, as the resulting string may still
contain user-supplied conversion specifiers for later interpolation by printf. Always use the proper secure idiom:
snprintf(buffer, sizeof(buffer), "%s", string);
Bugs:
The conversion formats %D, %O, and %U are not standard and are provided only for backward compatibility. The effect of padding
the %p format with zeros (either by the 0 flag or by specifying a precision), and the benign effect (i.e., none) of the #
flag on %n and %p conversions, as well as other nonsensical combinations such as %Ld, are not standard; such combinations
should be avoided. The printf family of functions do not correctly handle multibyte characters in the format argument.
Parameters
Return value
int |
Upon successful return, these functions return the number of characters printed (not including the trailing \0 used to end
output to strings). The functions snprintf and vsnprintf do not write more than size bytes (including the trailing \0). If
the output was truncated due to this limit then the return value is the number of characters (not including the trailing \0)
which would have been written to the final string if enough space had been available. Thus, a return value of size or more
means that the output was truncated. If an output error is encountered, a negative value is returned.None of these functions
support long double length modifiers. Floating point format specifiers support a maximum precision of 15 digits.
|
|
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int putc(int, FILE *);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int putchar(int);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int puts(const char *);
Description
Parameters
Return value
Interface status: |
externallyDefinedApi |
|
IMPORT_C int remove(const char *);
Description
The remove function removes the file or directory specified by file.
If file specifies a directory, remove (file); is the equivalent of rmdir (file); Otherwise, it is the equivalent of unlink
(file);
Examples:
/* this program shows deleting a file using remove */
#include <stdio.h>
int main()
{
char *name = "C:\input.txt";
FILE *fp = fopen(name, "w+");
if (fp == NULL)
{
printf ("fopen failed");
return -1;
}
fprintf(fp,"hello world");
fclose(fp);
remove(name);
fp=fopen(name,"r");
if (fp == NULL)
{
printf ("file has been deleted already");
}
else
{
printf("remove failed");
return -1;
}
return 0;
}
Output
file has been deleted already
Limitations:
-
The file parameter of the remove(const char *)
remove(const char *)
function should not exceed 256 characters in length.
-
P.I.P.S. only simulates link files and does not distinguish between hard and symbolic links.
-
KErrNotReady of Symbian error code is mapped to ENOENT, which typically means drive not found or filesystem not mounted on
the drive.
Parameters
Return value
int |
Upon successful completion, reomve return 0. Otherwise, -1 is returned and the global variable errno is set to indicate the
error.
|
|
See also:
rename(const char *,const char *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int rename(const char *, const char *);
Description
The rename system call causes the link named oldpath to be renamed as to. If to exists, it is first removed. Both oldpath
and newpath must be of the same type (that is, both directories or both non-directories), and must reside on the same file
system.
If the final component of oldpath is a symbolic link, the symbolic link is renamed, not the file or directory to which it
points.
If a file with a symbolic link pointing to it is renamed, then a subsequent open call on the symbolic link file would automatically
remove the link file, i.e consider a symbolic file link.x pointing to a file abc.x. If the file abc.x is renamed to abcd.x
then, a subsequent open call on link.x file would automatically remove link.x file.
Note:
-
rename(const char *,const char *)
rename(const char *,const char *)
does not differentiate between hard and soft links.
-
If the specified file is a dangling link file, then this link file will be automatically removed.
Limitations:
Examples:
/*
Detailed description: This sample code demonstrates usage of rename system call.
Preconditions: Example.cfg file should be present in the current working directory.
*/
#include <stdio.h>
int main()
{
if(rename("Example.txt" , "Example2.txt") < 0 ) {
printf("Failed to rename Example.txt");
return -1;
}
printf("Rename successful");
return 0;
}
Output
Rename successful
Parameters
const char * |
|
const char * |
|
|
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C void rewind(FILE *);
Description
Parameters
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int scanf(const char *,...);
Description
The scanf family of functions scans input according to a format as described below. This format may contain conversion specifiers;
the results from such conversions, if any, are stored through the pointer arguments. The scanf function reads input from the
standard input stream stdin, fscanf reads input from the stream pointer stream, and sscanf reads its input from the character
string pointed to by str. The vfscanf function is analogous to vfprintf and reads input from the stream pointer stream using
a variable argument list of pointers (see stdarg).
The vscanf function scans a variable argument list from the standard input and the vsscanf function scans it from a string;
these are analogous to the vprintf and vsprintf functions respectively. Each successive pointer argument must correspond properly
with each successive conversion specifier (but see the * conversion below). All conversions are introduced by the % (percent
sign) character. The format string may also contain other characters. White space (such as blanks, tabs, or newlines) in the
format string match any amount of white space, including none, in the input. Everything else matches only itself. Scanning
stops when an input character does not match such a format character. Scanning also stops when an input conversion cannot
be made (see below).
Examples:
/* this program shows scanning from file using fscanf */
#include <stdio.h>
int main(void)
{
char x;
int ret;
char* filename="c:\ScanfTest1.txt";
FILE *fp=fopen(filename,"w");
fprintf(fp,"%s","abcdesdafg");
fclose(fp);
fp=fopen(filename,"r");
ret=fscanf(fp,"%c",&x;);
fclose(fp);
printf("fscanf returned:%c",x);
unlink(filename);
getchar();
if(ret!= 1)
return -1;
else
return 0;
}
Output
fscanf returned:a
Examples:
/* this program shows scanning from file using fscanf */
#include <stdio.h>
int main(void)
{
char x;
int ret;
char* filename="c:\ScanfTest1.txt";
FILE *fp=fopen(filename,"w");
fprintf(fp,"%s","abcdesdafg");
fclose(fp);
fp=fopen(filename,"r");
ret=fscanf(fp,"%c",&x;);
fclose(fp);
printf("fscanf returned:%c",x);
unlink(filename);
getchar();
if(ret!= 1)
return -1;
else
return 0;
}
Output
fscanf returned:a
Parameters
Return value
int |
These functions return the number of input items assigned, which can be fewer than provided for, or even zero, in the event
of a matching failure. Zero indicates that, while there was input available, no conversions were assigned; typically this
is due to an invalid input character, such as an alphabetic character for a '%d' conversion. The value EOF is returned if
an input failure occurs before any conversion such as an end-of-file occurs. If an error or end-of-file occurs after conversion
has begun, the number of conversions which were successfully completed is returned.None of these functions support long double
data types.
|
|
See also:
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
...
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
strtod(const char *,char **)
strtod(const char *,char **)
Convert string to double-precision floating-point value. Parses string interpret...
strtol(const char *,char **,int)
strtol(const char *,char **,int)
Convert string to long integer.
strtoul(const char *,char **,int)
strtoul(const char *,char **,int)
Convert string to unsigned long integer. Parses string interpreting its content ...
wscanf(const wchar_t *,...)
wscanf(const wchar_t *,...)
...
Interface status: |
externallyDefinedApi |
|
IMPORT_C void setbuf(FILE *, char *);
Description
The three types of buffering available are unbuffered, block buffered, and line buffered. When an output stream is unbuffered,
information appears on the destination file or terminal as soon as written; when it is block buffered many characters are
saved up and written as a block; when it is line buffered characters are saved up until a newline is output or input is read
from any stream attached to a terminal device (typically stdin). The function fflush may be used to force the block out early.
Normally all files are block buffered. When the first I/O operation occurs on a file, malloc is called, and an optimally-sized
buffer is obtained. If a stream refers to a terminal (as stdout normally does) it is line buffered. The standard error stream
stderr is always unbuffered.
The setvbuf function may be used to alter the buffering behavior of a stream. The mode argument must be one of the following
three macros:
_IONBF
unbuffered
_IOLBF
line buffered
_IOFBF
fully buffered
The size argument may be given as zero to obtain deferred optimal-size buffer allocation as usual. If it is not zero, then
except for unbuffered files, the buf argument should point to a buffer at least size bytes long; this buffer will be used
instead of the current buffer. If buf is not NULL, it is the caller's responsibility to free this buffer after closing the
stream.
The setvbuf function may be used at any time, but may have peculiar side effects (such as discarding input or flushing output)
if the stream is "active". Portable applications should call it only once on any given stream, and before any I/O is performed.
The other three calls are, in effect, simply aliases for calls to setvbuf. Except for the lack of a return value, the setbuf
function is exactly equivalent to the call
setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
The setbuffer function is the same, except that the size of the buffer is up to the caller, rather than being determined by
the default BUFSIZ. The setlinebuf function is exactly equivalent to the call:
setvbuf(stream, (char *)NULL, _IOLBF, 0);
Examples:
/* this program shows setting up a buffer using setbuf * /
#include <stdio.h>
int main()
{
FILE *fp;
char FullBuf[100];
char msg[100];
char * rptr;
char name[20] = "c:\setbuf1.txt";
fp = fopen(name, "w+");
if (fp == NULL)
{
printf ("fopen failed");
return -1;
}
setbuf(fp, FullBuf); // Fully buffered
if (ferror(fp))
{
printf ("setbuf failed");
fclose(fp);
unlink(name);
return -1;
}
fprintf(fp, "we are trying to buffer 20 characters at once ");
fclose(fp);
fp=fopen(name,"r");
rptr = fgets(msg,100,fp);
if(rptr == NULL)
{
printf("fgets failed");
fclose(fp);
return -1;
}
printf("file reading returned \"%s\",msg);
fclose(fp);
unlink(name);
return 0;
}
Output
file reading returned "we are trying to buffer 20 characters at once"
Parameters
__sFILE __sFILE * |
|
char * |
Note: This description also covers the following functions - setbuffer(FILE *,char *,int) setbuffer(FILE *,char *,int) setlinebuf(FILE *) setlinebuf(FILE *) setvbuf(FILE *,char *,int,size_t) setvbuf(FILE *,char *,int,size_t)
|
|
See also:
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
malloc(size_t)
malloc(size_t)
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
setvbuf(FILE *,char *,int,size_t)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int setvbuf(FILE *, char *, int, size_t);
Description
Parameters
Return value
See also:
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
malloc(size_t)
malloc(size_t)
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
sprintf(char *,const char *,...)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int sprintf(char *, const char *,...);
Description
Parameters
Return value
See also:
sscanf(const char *,const char *,...)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int sscanf(const char *, const char *,...);
Description
Parameters
const char * |
|
const char * |
|
... |
|
|
Return value
See also:
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
...
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
strtod(const char *,char **)
strtod(const char *,char **)
Convert string to double-precision floating-point value. Parses string interpret...
strtol(const char *,char **,int)
strtol(const char *,char **,int)
Convert string to long integer.
strtoul(const char *,char **,int)
strtoul(const char *,char **,int)
Convert string to unsigned long integer. Parses string interpreting its content ...
wscanf(const wchar_t *,...)
wscanf(const wchar_t *,...)
...
Interface status: |
externallyDefinedApi |
|
IMPORT_C FILE* tmpfile(void);
Description
Note: This description also covers the following functions - tmpnam(char *)
tmpnam(char *)
tempnam(const char *,const char *)
tempnam(const char *,const char *)
The tmpfile function returns a pointer to a stream associated with a file descriptor returned by the routine mkstemp . The
created file is unlinked before tmpfile returns, causing the file to be automatically deleted when the last reference to it
is closed. The file is opened with the access value 'w+'. The file is created in the directory determined by the environment
variable TMPDIR if set. The default location if TMPDIR is not set is /tmp .
The tmpnam function returns a pointer to a file name, in the P_tmpdir directory, which did not reference an existing file at some
indeterminate point in the past. P_tmpdir is defined in the include file #include <stdio.h>. If the argument str is non- NULL , the file name is copied to the buffer it references. Otherwise,
the file name is copied to a static buffer. In either case, tmpnam returns a pointer to the file name.
The buffer referenced by str is expected to be at least L_tmpnam bytes in length. L_tmpnam is defined in the include file
#include <stdio.h
>.
The tempnam function is similar to tmpnam , but provides the ability to specify the directory which will contain the temporary
file and the file name prefix.
The environment variable TMPDIR (if set), the argument tmpdir (if non- NULL ), the directory P_tmpdir , and the directory
/tmp are tried, in the listed order, as directories in which to store the temporary file.
The argument prefix , if non- NULL , is used to specify a file name prefix, which will be the first part of the created file
name. The tempnam function allocates memory in which to store the file name; the returned pointer may be used as a subsequent
argument to free .
Examples:
#include<stdio.h> //SEEK_SET, printf, tmpfile, FILE
#include<sys/stat.h> //S_IWUSR
int main()
{
//create the tmp directory
mkdir("c:\tmp", S_IWUSR);
//call tmpfile to create a tempory file
FILE* fp = tmpfile();
char buf[10];
if(fp)
{
//write onto the file
fprintf(fp, "%s", "hello");
fflush(fp);
//seek to the beginning of the file
fseek(fp, SEEK_SET, 0); //beg of the file
//read from the file
fscanf(fp, "%s", buf);
fflush(fp);
//close the file
fclose(fp);
}
printf("buf read: %s", buf);
return 0;
}
Output
buf read: hello
#include<stdio.h> //tmpnam, printf, FILE
#include<sys/stat.h> //S_IWUSR
#include<errno.h> //errno
int main()
{
//create a directory c:\system emp
mkdir("c:\system\temp", S_IWUSR);
char buf[L_tmpnam];
char rbuf[10];
//call tmpnam() to create a file
char *rval = tmpnam(buf);
errno = 0;
//open the file with the name returned by tmpnam()
FILE *fp = fopen(buf, "w");
if (fp == NULL)
{
printf("fopen of file returned by tmpnam() failed - (*__errno()) %d ", errno);
return -1;
}
if(fp)
{
fprintf(fp, "%s", "check");
fclose(fp);
}
fp = fopen(buf, "r");
if(fp)
{
fscanf(fp, "%s", rbuf);
fclose(fp);
}
printf("read from file: %s", rbuf);
printf("argument buf: %s", buf);
printf("return value: %s", rval);
return 0;
}
Output
read from file: check
argument buf: /System/temp/tmp.0.U9UPTx
return value: /System/temp/tmp.0.U9UPTx
Limitations:
Return value
__sFILE __sFILE *
|
The tmpfile function returns a pointer to an open file stream on success, and a NULL pointer on error. The tmpnam and tempfile
functions return a pointer to a file name on success, and a NULL pointer on error.
|
|
Interface status: |
externallyDefinedApi |
|
IMPORT_C char* tmpnam(char *);
Description
Parameters
Return value
Interface status: |
externallyDefinedApi |
|
IMPORT_C int ungetc(int, FILE *);
Description
The ungetc function pushes the character c (converted to an unsigned char) back onto the input stream pointed to by fp . The
pushed-back characters will be returned by subsequent reads on the stream (in reverse order). A successful intervening call,
using the same stream, to one of the file positioning functions ( fsetpos or rewind ) will discard the pushed back characters.
One character of push-back is guaranteed, but as long as there is sufficient memory, an effectively infinite amount of pushback
is allowed.
If a character is successfully pushed-back, the end-of-file indicator for the stream is cleared. The file-position indicator
is decremented by each successful call to ungetc ; if its value was 0 before a call, its value is unspecified after the call.
Examples:
/* this pushing character to file stream using ungetc */
#include <stdio.h>
int main(void)
{
int c;
FILE* fp = fopen("c:\input.txt", "w");
fprintf(fp, "%s", "abcdefghijklmn");
fprintf(fp, "%c", '');
fprintf(fp, "%s", "fdsfdsafsdabcdefghijklmn");
fclose(fp);
char * name = "C:\input.txt";
fp = fopen(name, "w+");
if (fp == NULL)
{
printf ("fopen failed");
return -1;
}
if(ungetc('a',fp)!='a') printf("ungetc failed");
fseek(fp,-1,SEEK_CUR);
c=getc(fp);
printf("character read from stream is \"%c\",c);
fclose(fp);
}
Output
character read from stream is "a"
Parameters
Return value
int |
The ungetc function returns the character pushed-back after the conversion, or EOF if the operation fails. If the value of
the argument c character equals EOF , the operation will fail and the fp will remain unchanged.
|
|
See also:
vfprintf(FILE *,const char *,va_list)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int vfprintf(FILE *, const char *, va_list);
Description
Parameters
Return value
See also:
vprintf(const char *,va_list)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int vprintf(const char *, va_list);
Description
Parameters
Return value
See also:
vsprintf(char *,const char *,va_list)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int vsprintf(char *, const char *, va_list);
Description
Parameters
Return value
See also:
snprintf(char *,size_t,const char *,...)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int snprintf(char *, size_t, const char *,...);
Description
Parameters
Return value
See also:
vfscanf(FILE *,const char *,va_list)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int vfscanf(FILE *, const char *, va_list);
Description
Parameters
Return value
See also:
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
...
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
strtod(const char *,char **)
strtod(const char *,char **)
Convert string to double-precision floating-point value. Parses string interpret...
strtol(const char *,char **,int)
strtol(const char *,char **,int)
Convert string to long integer.
strtoul(const char *,char **,int)
strtoul(const char *,char **,int)
Convert string to unsigned long integer. Parses string interpreting its content ...
wscanf(const wchar_t *,...)
wscanf(const wchar_t *,...)
...
vscanf(const char *,va_list)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int vscanf(const char *, va_list);
Description
Parameters
Return value
See also:
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
...
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
strtod(const char *,char **)
strtod(const char *,char **)
Convert string to double-precision floating-point value. Parses string interpret...
strtol(const char *,char **,int)
strtol(const char *,char **,int)
Convert string to long integer.
strtoul(const char *,char **,int)
strtoul(const char *,char **,int)
Convert string to unsigned long integer. Parses string interpreting its content ...
wscanf(const wchar_t *,...)
wscanf(const wchar_t *,...)
...
vsnprintf(char *,size_t,const char *,va_list)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int vsnprintf(char *, size_t, const char *, va_list);
Description
Parameters
Return value
See also:
vsscanf(const char *,const char *,va_list)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int vsscanf(const char *, const char *, va_list);
Description
Parameters
Return value
See also:
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
mbrtowc(wchar_t *,const char *,size_t,mbstate_t *)
...
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
strtod(const char *,char **)
strtod(const char *,char **)
Convert string to double-precision floating-point value. Parses string interpret...
strtol(const char *,char **,int)
strtol(const char *,char **,int)
Convert string to long integer.
strtoul(const char *,char **,int)
strtoul(const char *,char **,int)
Convert string to unsigned long integer. Parses string interpreting its content ...
wscanf(const wchar_t *,...)
wscanf(const wchar_t *,...)
...
Interface status: |
externallyDefinedApi |
|
IMPORT_C FILE* fdopen(int, const char *);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int fileno(FILE *);
Description
Parameters
Return value
popen(const char *,const char *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C FILE* popen(const char *, const char *);
Description
The popen function opens a process by creating a pipe, forking, and invoking the shell. Since a pipe is by definition unidirectional,
the type argument may specify only reading or writing, not both. The resulting stream is correspondingly read-only ("r") or
write-only "w". If type is anything other than this the behavior is undefined.
The command argument is a pointer to a null-terminated string containing a shell command line. This command is passed to /bin/sh
using the - c flag; interpretation, if any, is performed by the shell.
The return value from popen is a normal standard I/O stream in all respects save that it must be closed with pclose rather
than fclose. Writing to such a stream writes to the standard input of the command. The command's standard output is the same
as that of the process that called popen, unless this is altered by the command itself. Conversely, reading from a "popened"
stream reads the command's standard output, and the command's standard input is the same as that of the process that called
popen.
Note that output popen streams are fully buffered by default.
The pclose function waits for the associated process to terminate and returns the exit status of the command as returned by
wait4.
Bugs:
Since the standard input of a command opened for reading shares its seek offset with the process that called popen, if the
original process has done a buffered read, the command's input position may not be as expected. Similarly, the output from
a command opened for writing may become intermingled with that of the original process. The latter can be avoided by calling
fflush before popen. Failure to execute the shell is indistinguishable from the shell's failure to execute command, or an
immediate exit of the command. The only hint is an exit status of 127. The popen function always calls sh and never calls
csh.
Parameters
const char * |
|
const char * |
Note: This description also covers the following functions - pclose(FILE *)
|
|
Return value
__sFILE __sFILE *
|
The popen function returns NULL if the fork or pipe calls fail, or if it cannot allocate memory. The pclose function returns
-1 if stream is not associated with a "popened" command, if stream already "pclosed" or if wait4 returns an error.
|
|
See also:
popen3(const char *,const char *,char **,int)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int popen3(const char *file, const char *cmd, char **envp, int fds[3]);
Description
Open stdin, stdout, and stderr streams and start external executable.
Parameters
const char *file |
|
const char *cmd |
|
char **envp |
|
int fds |
|
|
Return value
Interface status: |
externallyDefinedApi |
|
IMPORT_C int ftrylockfile(FILE *);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C void flockfile(FILE *);
Description
These functions provide explicit application-level locking of stdio streams. They can be used to avoid output from multiple
threads being interspersed, input being dispersed among multiple readers, and to avoid the overhead of locking the stream
for each operation.
The flockfile function acquires an exclusive lock on the specified stream. If another thread has already locked the stream
flockfile will block until the lock is released.
The ftrylockfile function is a non-blocking version of flockfile; if the lock cannot be acquired immediately ftrylockfile
returns non-zero instead of blocking.
The funlockfile function releases the lock on a stream acquired by an earlier call to flockfile or ftrylockfile.
These functions behave as if there is a lock count associated with each stream. Each time flockfile is called on the stream
the count is incremented and each time funlockfile is called on the stream the count is decremented. The lock is only actually
released when the count reaches zero.
Examples:
#include <stdio.h>
#include <unistd.h>
#include <pthread.h> //link to the lib -libpthread
void* somefun(void* args)
{
FILE *fp = (FILE *)args;
printf("in thr 2");
flockfile(fp);
printf("aquired lock!");
fputc('a', fp); //fputc_unlocked() is more relevant
printf("after a from thr 2");
sleep(3);
printf("after sleep from thr 2");
fputc('b', fp);
printf("after b from thr 2");
fputc('c', fp);
printf("after c from thr 2");
funlockfile(fp);
fclose(fp);
}
int main()
{
pthread_t obj;
FILE *fp = fopen("c:\chk.txt", "w");
if(fp)
{
flockfile(fp);
fputc('x', fp); //fputc_unlocked() is more relevant
printf("after x from thr 1");
sleep(5);
printf("after sleep from thr 1");
pthread_create(&obj;, NULL, somefun, fp);
printf("after calling thr 2 from thr 1");
fputc('y', fp);
printf("after y from thr 1");
fputc('z', fp);
printf("after z from thr 1");
funlockfile(fp);
printf("gave up lock in thr 1");
}
pthread_exit((void *)0);
}
Output
after x from thr 1
after sleep from thr 1
in thr 2
after calling thr 2 from thr 1
after y from thr 1
after z from thr 1
gave up lock in thr 1
acquired lock!
after a from thr 2
after sleep from thr 2
after b from thr 2
after c from thr 2
Note: The printing takes quite some time and hence the
output may not look exactly like the above one.
(try printing to the files if you are very particular)
#include <stdio.h>
#include <unistd.h>
#include <pthread.h> //link to lib -libpthread
#include <errno.h>
void* somefun(void* args)
{
FILE *fp = (FILE *)args;
printf("in thr 2
");
int i = ftrylockfile(fp);
if(i == 0)
{
printf("aquired lock!");
fputc('a', fp);
printf("after a from thr 2");
sleep(3);
printf("after sleep from thr 2");
fputc('b', fp);
printf("after b from thr 2");
fputc('c', fp);
printf("after c from thr 2");
funlockfile(fp);
printf("gave up lock in thr 2");
}
else
printf("couldn't aquire lock");
}
int main()
{
pthread_t obj;
FILE *fp = fopen("c:\chk.txt", "w");
if(fp)
{
flockfile(fp);
fputc('x', fp);
printf("after x from thr 1");
sleep(5);
printf("after sleep from thr 1");
pthread_create(&obj;, NULL, somefun, fp);
printf("after calling thr 2 from thr 1");
fputc('y', fp);
printf("after y from thr 1");
fputc('z', fp);
printf("after z from thr 1");
funlockfile(fp);
printf("gave up lock in thr 1");
sleep(5);
fclose(fp);
}
pthread_exit((void *)0);
}
Output
after x from thr 1
after sleep from thr 1
in thr 2
couldn't acquire lock
after calling thr 2 from thr 1
after y from thr 1
after z from thr 1
gave up lock in thr 1
Note: The printing takes quite some time and hence the
output may not look exactly like the above one.
(try printing to the files if you are very particular)
Parameters
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C void funlockfile(FILE *);
Description
Parameters
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int getc_unlocked(FILE *);
Description
Parameters
Return value
See also:
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
ungetc(int,FILE *)
ungetc(int,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int getchar_unlocked(void);
Description
Refer to fgetc(FILE *)
fgetc(FILE *)
for the documentation
Return value
See also:
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
ungetc(int,FILE *)
ungetc(int,FILE *)
putc_unlocked(int,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int putc_unlocked(int, FILE *);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int putchar_unlocked(int);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int getw(FILE *);
Description
Parameters
Return value
See also:
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
ungetc(int,FILE *)
ungetc(int,FILE *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int putw(int, FILE *);
Description
Parameters
Return value
See also:
tempnam(const char *,const char *)
Interface status: |
externallyDefinedApi |
|
IMPORT_C char* tempnam(const char *, const char *);
Description
Refer to tmpfile(void)
tmpfile(void)
for the documentation
Parameters
const char * |
|
const char * |
|
|
Return value
asprintf(char **,const char *,...)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int asprintf(char **, const char *,...);
Description
Parameters
Return value
See also:
setbuffer(FILE *,char *,int)
Interface status: |
externallyDefinedApi |
|
IMPORT_C void setbuffer(FILE *, char *, int);
Description
Parameters
See also:
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
malloc(size_t)
malloc(size_t)
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
Interface status: |
externallyDefinedApi |
|
IMPORT_C int setlinebuf(FILE *);
Description
Parameters
Return value
See also:
fopen(const char *,const char *)
fopen(const char *,const char *)
Open a file. Opens the file which name is stored in the filename string and retu...
fread(void *,size_t,size_t,FILE *)
fread(void *,size_t,size_t,FILE *)
Read block of data from a stream. Read count number of items each one with a siz...
malloc(size_t)
malloc(size_t)
printf(const char *,...)
printf(const char *,...)
Print formatted data to stdout. Prints to standard output a sequence of argument...
vasprintf(char **,const char *,va_list)
Interface status: |
externallyDefinedApi |
|
IMPORT_C int vasprintf(char **, const char *, va_list);
Description
Parameters
Return value
See also:
Interface status: |
externallyDefinedApi |
|
IMPORT_C int setecho(int fd, uint8_t echoval);
Description
Notes: The given fd should be that of a console. If the stdio redirection server is used to redirect the stdin/stdout of a
process and if the given fd maps to one of those, then the stdin will only be affected by this call. Write operations on this
fd will not be affected. The earlier behavior is retained if setecho(int,uint8_t)
setecho(int,uint8_t)
fails.
Parameters
int fd |
|
uint8_t uint8_t echoval |
Turns On/Off the echo for the input characters. If echoval is 0, the echo is turned off and nothing gets echoed on the console.
If echoval is 1, the echo is turned on. If echoval is anything else, the echo is turned off and the given printable character
will be echoed instead the actual input character.
|
|
Return value
int |
Upon successfull completion it returns 0, otherwise -1, setting the errno.
|
|
stdio.h Global variables