- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 35163 Articles for Programming
362 Views
The fgets() function returns a line from a file. It returns a string of up to length - 1 bytes read from the file pointed to by file_pointer.Syntaxfgets (file_pointer, length);Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().length − Reading ends when length - 1 bytes have been read, on a newline, or on EOF (whichever comes first).ReturnThe fgets() function returns a string of up to length - 1 bytes read from the file pointed to by fle_pointer.ExampleThe following is an example. Here, we have a file “one.txt” with ... Read More
383 Views
The fgetcsv() function parses a line from an open file to check for CSV fields. It returns an array containing the fields read.Syntaxfgetcsv(file_pointer, length, delimiter, enclosure, escape)Parametersfile_pointer − A valid file pointer to a file successfully opened by fopen(), popen(), or fsockopen().length − Maximum length of a line.delimiter − Character that specifies the field separator. Default is comma ( , )enclosure − Set the field enclosure character. Defaults as a double quotation mark.escape − Set the escape character. Defaults as a backslash (\).ReturnThe fgetcsv() function returns an array containing the fields read.ExampleLet’s say we have the following “products.csv” CSV file.laptop, ... Read More
121 Views
The fgetc() function gets a character from an open file. It returns false on eof, or a string containing a single character read from the file pointed to by file_pointerSyntaxfgetc(file_pointer)Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()).ReturnThe fgetc() function returns false on eof, or a string containing a single character read from the file pointed to by file_pointer.ExampleThe following is an example. This reads the first character from the file.The following is the output. Let’s say our file “two.txt” has the text ... Read More
165 Views
The fflush() function flushes the output to an open file. This function forces a write of all buffered output to the resource pointed to by the file handle.Syntaxfflush(file_pointer)Parametersfile_pointer − Specify the open file stream.ReturnThe fflush() function returns.TRUE on successFALSE on failureExampleOutputtest lineLet us see another example.ExampleOutputJava is a programming language. JavaScript is a scripting language.
193 Views
The feof() function tests for end-of-file on a file pointer. It returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE.Syntaxfeo(file_pointer)Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose())ReturnThe feof() function returns TRUE if the file pointer is at EOF or an error occurs, otherwise returns FALSE.ExampleOutputFirst line
401 Views
The fclose() function closes an open file pointer. The function returns TRUE on success and FALSE on failure.Syntaxfclose(file_pointer)Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().ReturnThe fclose() function returns.TRUE on successFALSE on failureExampleOutputtrueLet us see another example. This shows a file which is opened, the content is returned using fgetsss and the file is closed with file pointer using file pointer.ExampleOutputThis is demo text
73 Views
The diskfreespace() function returns the available free space in a directory and is an alias of disk_free_space().Syntaxdiskfreespace(dir_name)Parametersdir_name − Directory to be specified.ReturnThe diskfreespace() function returns the free space in bytes.Example Live DemoOutput832931168256Let us see another example.Example Live DemoOutputFree Space: 832931168256
91 Views
The disk_total_space() function returns the total size of a directory. It returns the total number of bytes of a directory.Syntaxdisk_total_space(dir_name)Parametersdir_name − Specify the name of the directory.ReturnThe disk_total_space() function returns the total available space in bytes.Example Live DemoOutput944459485184Let us see another example.Example Live DemoOutputTotal Available Space: 944459485184
94 Views
The disk_free_space() function returns directory’s free space in bytes.Syntaxdisk_free_space(dir_name);Parametersdir_name − Specify the name of the directory.ReturnThe disk_free_space() function returns bytes of available space in a file. It returns false on failure.Example Live DemoOutput832806768640
373 Views
The dirname() function returns the directory name from the specified path. If the path has no slashes, a dot ('.') is returned. This indicates the current directory.Syntaxdirname(file_path)Parametersfile_path − File to be specified.ReturnThe dirname() function returns the path of the directory.Example Live DemoOutputName of the directory: D:/amitLet us see another example.Example Live DemoOutputName of the directory: /amit
To Continue Learning Please Login
Login with Google