Found 33676 Articles for Programming

tmpfile() function in C

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

1K+ Views

The function tmpfile() creates a temporary file in binary update mode in C. It initializes in header file of a C program. It always returns a null pointer if the temporary file cannot be created. The temporary file deleted automatically just after the termination of program.SyntaxFILE *tmpfile(void)Return valueIf file creation is successful, the function returns a stream pointer to the temporary file created. If the file cannot be created, NULL pointer is returned.AlgorithmBegin.    Declare an array variable c[] to the character datatype and take a character data string.    Initialize a integer variable i ← 0.    Declare a ... Read More

tellp() in file handling with C++

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

In C++ file handling, the tellp() function is used with output streams, and returns the current put position of the pointer in the stream. It returns an integer data type, representing the current position of the stream pointer.tellp() method takes no parameter. It is written as: pos_type tellp();AlgorithmBegin.    Create an object newfile against the class fstream.    Call open() method to open a file “tpoint.txt” to perform write operation using object newfile.    Insert data into the file object newfile.    Call the tellp() method to print the present position of the pointer in the file object.    Call ... Read More

The removeAll() method of AbstractSequentialList in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

93 Views

The removeAll() is a method inherited from AbstractCollection class. It removes all the elements of this collection that are also contained in the specified collection.The syntax is as follows:public boolean removeAll(Collection c)Here, the parameter c is the collection having elements to be removed from this collection.To work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList removeAll() method in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {      public static void main(String[] args) {       AbstractSequentialList absSequential = new LinkedList();       absSequential.add(210); ... Read More

The containsAll() method of AbstractSequentialList in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

114 Views

The containsAll() method of the AbstractSequentialList checks for all the elements in this collection. It returns TRUE if all this collection contains all the elements in the specified collection i.e. if the two collections are same.The syntax is as follows:public boolean containsAll(Collection c)Here, c is the collection to be checkedTo work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList containsAll() method in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) {       AbstractSequentialList absSequential = new LinkedList();   ... Read More

Read file line by line using C++

karthikeya Boyini
Updated on 14-Sep-2023 13:43:23

26K+ Views

This is a C++ program to read file line by line.Inputtpoint.txt is having initial content as "Tutorials point."OutputTutorials point.AlgorithmBegin    Create an object newfile against the class fstream.    Call open() method to open a file “tpoint.txt” to perform write operation using object newfile.    If file is open then       Input a string “Tutorials point" in the tpoint.txt file.       Close the file object newfile using close() method.    Call open() method to open a file “tpoint.txt” to perform read operation using object newfile.    If file is open then       Declare a ... Read More

Read Data from a Text File using C++

Samual Sam
Updated on 30-Jul-2019 22:30:25

12K+ Views

This is a C++ program to read data from a text file.Inputtpoint.txt is having initial content as “Tutorials point.”OutputTutorials point.AlgorithmBegin    Create an object newfile against the class fstream.    Call open() method to open a file “tpoint.txt” to perform write operation using object newfile.    If file is open then       Input a string “Tutorials point" in the tpoint.txt file.       Close the file object newfile using close() method.    Call open() method to open a file “tpoint.txt” to perform read operation using object newfile.    If file is open then       Declare ... Read More

The toArray(T[]) method of AbstractSequentialList in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

186 Views

The difference between toArray() and toArray(T[] arr) is that both the methods returns an array containing all of the elements in this collection, but the latter has some additional features i.e. the runtime type of the returned array is that of the specified array.The syntax is as follows:public T[] toArray(T[] arr)Here, arr is the array into which the elements of this collection are to be stored, To work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList toArray() method in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class ... Read More

Merge contents of two files into a third file using C

Revathi Satya Kondra
Updated on 30-May-2025 17:52:18

1K+ Views

In C language, file handling is used for various file actions such as to write, read, merge, etc. Merging Contents of Two Files into a Third FileTo merge the contents of two files into a third file, you need to open the first two files (whose content will be merged into the third file) in read mode and the third file in write mode. After opening the files, read the contents of the first file and write them to the third file, and similarly with the second file and appending them to the third file. Example Scenario Imagine these are ... Read More

How to read a text file with C++?

Revathi Satya Kondra
Updated on 13-Jun-2025 13:18:16

75K+ Views

In C++, you can read data from a text file using file handling features provided by the header. This is useful when you want your program to read input stored in a file instead of typing it every time. To do this, you use a special object called ifstream (input file stream), which helps your program open the file and read its contents line by line or word by word. Reading a text file is helpful when: You want to process saved data (like scores, settings, or logs). You want to ... Read More

How to append text to a text file in C++?

Revathi Satya Kondra
Updated on 12-Jun-2025 13:55:57

7K+ Views

Appending text means adding new content to an existing file without removing its current content. In C++, this can be done by opening the file in append mode and writing the specified content to it. Steps to Append Text to a Text File You need to follow the below steps to open a file in append mode and append the content to it: First of all, you need to include the header file. Them, create an ofstream object to write to the file. Open the file in append mode using the ios::app flag. Use the

Advertisements