libft
Loading...
Searching...
No Matches
Files | Functions
File Descriptor Output

Output utilities for writing to file descriptors. More...

Files

file  ft_output.c
 File descriptor-based output functions.
 
file  ft_output.h
 File descriptor-based output functions.
 

Functions

void ft_putchar_fd (char c, int fd)
 Writes a single character to a file descriptor.
 
void ft_putendl_fd (char *s, int fd)
 Writes a string followed by a newline to a file descriptor.
 
void ft_putnbr_fd (int n, int fd)
 Writes an integer to a file descriptor.
 
int ft_putstr_fd (char *str, int fd)
 Writes a string to a file descriptor.
 

Detailed Description

Output utilities for writing to file descriptors.

Functions that output characters, strings, and integers to a given file descriptor. These are useful in systems without standard output libraries.

This group includes:

Function Documentation

◆ ft_putchar_fd()

void ft_putchar_fd ( char  c,
int  fd 
)

#include <include/ft_output.h>

Writes a single character to a file descriptor.

This function writes the character c to the file specified by fd. It is primarily used for outputting a single character to a file or standard output.

Parameters
cThe character to write.
fdThe file descriptor to which the character will be written.

◆ ft_putendl_fd()

void ft_putendl_fd ( char *  s,
int  fd 
)

#include <include/ft_output.h>

Writes a string followed by a newline to a file descriptor.

This function writes the string s followed by a newline character (\n) to the file descriptor fd. Commonly used to print lines of text.

Parameters
sThe string to write.
fdThe file descriptor to which the string and newline will be written.

◆ ft_putnbr_fd()

void ft_putnbr_fd ( int  n,
int  fd 
)

#include <include/ft_output.h>

Writes an integer to a file descriptor.

Outputs the integer n as a string of digits to the given fd. Handles negative numbers and the special case of INT_MIN.

Parameters
nThe integer to write.
fdThe file descriptor to which the integer will be written.

◆ ft_putstr_fd()

int ft_putstr_fd ( char *  str,
int  fd 
)

#include <include/ft_output.h>

Writes a string to a file descriptor.

This function writes the null-terminated string str to the file descriptor fd. It handles system interruptions (e.g., EINTR) and retries as needed until the full string is written or an unrecoverable error occurs.

Parameters
strThe string to write.
fdThe file descriptor to which the string will be written.
Returns
The total number of bytes written, or -1 on error.