File Manipulation Functions in C

Question: What are File Manipulation Functions in C Language Answer: Functions which manipulate files without performing I/O with them are called file manipulation functions. They are prototyped below int remove(char const *filename); int rename(char const *oldname, char const *newname); ‘remove()’ function can be used to explicitly close/delete a file specified by argument. If the specified … Read more

advertisement

Temporary Files in C – tmpfile() and tmpnam()

Question: What are Temporary Files? Answer: Sometimes, a program can use a file to hold data temporarily. This file is deleted automatically when program is finished or we can explicitly close the file using ‘fclose()’ when it’s no longer required. The ‘tmpfile()’ function opens a unique temporary file in binary read/write (w+b) mode. It’s prototyped … Read more

advertisement

What are Stream Error Functions in C Language?

Question: What are Stream Error Functions in C Language? Answer: We have functions in ANSI C specification which are used to determine the state of a stream. These are prototyped below, int feof(FILE *stream); int ferror(FILE *stream); void clearerr(FILE *stream); ‘feof()’ returns TRUE if stream is currently at end of file. Well! We have already … Read more

advertisement

Which Functions in C can we Use to Modify Buffering?

Question: Which Functions in C can we Use to Modify Buffering? Answer: As we know streams are mostly fully buffered and have default buffer size. This is defined in ‘stdio.h’ header. Below included code fragment, taken from ‘stdio.h’, indicates default buffer size. /* Default buffer size. */ #ifndef BUFSIZ # define BUFSIZ _IO_BUFSIZ #endif Sometimes, … Read more

advertisement

Flushing and Seeking Functions in C

Question: What are Flushing and Seeking Functions in C and What are they Used for in a Program Answer: Let’s recall that whenever we need to perform read and write operations with files in C programs we must open a stream for file and access that stream to perform desired operations with file. These streams … Read more

advertisement

What is Binary File I/O in C?

Question: What is Binary I/O in C Programming? Answer: By now, we are familiar with File I/O on text streams. We have seen that when we perform I/O with numeric values, for ex. integers, floats etc., value is firstly converted according to format code in the format string before reading from or writing to the … Read more

advertisement

Formatted and Unformatted Input/Output Functions in C

Question: What is Formatted and Unformatted Line I/O in C Programming? Answer: Unformatted line I/O merely reads strings and/or writes strings. There’s no conversions of numeric values according to specific format. gets and puts family of functions perform unformatted line I/O. Let’s see their prototypes below char *fgets(char *buffer, int buffer_size, FILE *stream); char *gets(char … Read more

advertisement

What is the ungetc() Function in C?

Question: What is the use of ungetc() Function in a C Program? Answer: We already have read from and written to individual characters from/to standard input/standard output and file I/O. The fact is that we can’t determine what character is on the stream until we have read it. Therefore we would read one character beyond … Read more

advertisement

Difference between True Functions and Character I/O Macros in C

Question: What is Difference Between True Functions and Character I/O Macros in C? Answer: We know that simplest I/O is individual characters I/O. getchar family of functions are used for reading single characters. These functions are prototyped below int fgetc(FILE *); int getc(FILE *); int getchar(void); Notice that fgetc() and getc() functions take desired stream … Read more

advertisement

Opening and Closing of File Streams in C

This C Tutorial Explains Opening and Closing of Streams using C programming. Recall that standard I/O library makes it very convenient to reading from and/or writing to files in a C program. This requires setting up a stream with the specified file. fopen() function is used to open a given file and associates a stream … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.