# C++ programming File Handling/ File Streams Examples

This section contains solved programs on C++ programming language File Handling programs, file stream examples.

Files/streams are the set of characters, using C++ programs, we will learn to write, read data in, from the files (both text and binary).

## List of C++ programming File Handling/ File Streams Examples

1. C++ program to create a file.
This program will create a simple text file, check file is created successfully or not and then close the file.
2. C++ program to read a text file.
This program will read text from text file, character by character in C++.
3. C++ program to write and read text in/from file.
This program will create a text file, check file created or not, if created it will write some text into the file and then read the text from the file.
4. C++ program to write and read values using variables in/from file.
This program will write/read variable values in/from the file.
5. C++ program to write and read object using read and write function.
This program is quite good, it will write, read object (through member functions) data in, from the file.
6. C++ program to demonstrate example of tellg() and tellp() function.
This program will demonstrate the example of tellg() and tellp() function, these are the get and put pointers to tell (return) the current position of file pointer (get/put).

7. C++ program to write and read time in/from binary file using fstream.
This program will write, read time in, from the file using fstream, fstream is the set of classes with member function, that are used to communicate (read, write and more) with the files.
8. C++ program to write and read an object in/from a binary file.
This program will write, read object (through member functions) in, from binary file.

## List of most popular & searched C++ programs

Showing latest posts on top

1. C++ Program to print right angled (Right oriented) pyramid of numbers.
In this program, we are going to learn how to print numbered pyramids of numbers (which is right angled and right oriented)? This post contains solved program with output and explanation.
2. C++ Program to print right angled pyramid of numbers.
In this program, we are going to learn how to print numbered pyramids of numbers? This post contains solved program with output and explanation.
3. C++ program to keep calculate the sum of the digits of a number until the number is a single digit.
In this program, we are going to implement logic to find sum of digits until the number is a single digits in C++ programming language.
4. How to skip some of the array elements in C++?
Learn: How to skip some of the array elements using C++ program? Here, using an example - we going to understand the concept of skipping some of the elements in C++.
5. Example of declaring and printing different constants in C++.
Declaring and printing different constant in C++: Here, we will learn to declare and print the value of different type of constants using C++ program.
6. C++ program to demonstrate example of delay() function.
dos.h delay() function in C++: Here, we will learn about the delay() function of dos.h header file in C++ through a simple example/program.
7. C++ program to print your name randomly on the screen with colored text.
Print your name on output screen randomly with colored text and background color using C++ program: Here you will learn some of the in-built functions that are using to print randomly, colored, print text of specified position etc.
8. Sieve of Eratosthenes to find prime numbers.
Learn: What is Sieve of Eratosthenes? And how to find prime numbers using this algorithm? This article contain solved program in C++ based on Sieve of Eratosthenes algorithm.

9. C++ program to print the maximum possible time using six of nine given single digits.
The Objective is to form the maximum possible time (in HH:MM:SS and 12 hour format) using any six of nine given single digits (not necessarily distinct).
10. Find last index of a character in a string using C++ program.
In this post, we are going to learn: how we can get the last index of a character in a string using C/C++ program using simple method?
11. C++ program to get week day from given date.
Learn: How to get weekday from a given date in C++ program? Here I am writing a C++ code by using you can able to access the weekday of given date.
12. Set date and time in Linux Operating System using C++ program.
Learn: How to define/set date and time in Linux Operating System using C++ program? Here we are using system() function to set date time.
13. Reading date and time from Linux operating system using C++ program.
Learn: How to get current date and time from Linux Operating System using C++ program? This program will read date, time from Operating system and print on the standard output device.
14. C++ program to get previous date of given date.
Given a date in DD, MM and YYYY format, you have to find the previous date.
15. C++ program to find total number of days in given month of year.
C++ program to find/print total number of days in a month, in this program, we will input month, year and program will print total number of days in that month, year.
16. C++ program to set network settings for IPv6 Network in Linux Devices.
Learn: How to set network settings for IPv6 based Network in Linux Devices? Here, we will learn to set IP address, prefix and Gateway for IPv6 based Network.

17. C++ program to pad octets of IP Address with Zeros.
Learn: How to pad IP Address octets with Zeros? In this C++ program, we will learn to pad each octet of an IP Address.
18. C++ program to set MAC address in Linux Devices.
Learn: How to set MAC address (physical address) in Linux devices using C++ program, this program is compiled and executed in G++ compiler.
19. C++ program to get MAC address of Linux based network device.
Learn: How to get/display MAC address of a Linux based network devices using C++ program? This program is compiled and executed in G++ compiler.
20. C++ program to set IP address, subnet mask, network gateway in Linux System.
Learn: How to set network settings like IP Address, Subnet Mask, Network Gateway using C++ program in Linux System using G++ Compiler?
21. C++ program to check given string is numeric or not.
Learn: How to check given string is numeric or not? In this C++ program, we are going to learn how to check whether a given a string is numeric or not?
22. C++ program to check given date is in valid format or not.
In this C++ program, we will read date and check whether it is in correct format or not?
23. C++ program to add seconds to the time.
Learn: How to add seconds in given time and print the time in HH:MM:SS format using C++ program, here we will add seconds in time (with using all conditions like time truncating etc).
24. C++ program to find Fibonacci number using different methods.
Learn: What to find fibonacci number using different methods, here you will find multiple methods to find the fibonacci number using C++ programs.
25. C++ program to find the next greatest number from the same set of digits.
Learn: How to find next greatest number from the same set of digits using a C++ program?
26. C++ program to convert number to word (up to four digits only).
Write a C++ program that will read an integer number (up to four digits) and convert it into words.
27. C++ program to check whether a string2 can be formed from string1.
This C++ program reads two Strings (String1 and String2) and checks whether String2 can be formed from String1, by printing ‘Yes’ otherwise ‘No’.
28. C++ program to print a spiral matrix.
Printing a spiral matrix up to given number using C++ program: A spiral matrix is a matrix consist of natural numbers up to n^2.
29. C++ program to find the frequency of a character in a string using Count Array.
This C++ program will read a string and count frequency of a character using count array.
30. C++ program to find factorial of large numbers using array.
Learn: How to find factorial of large numbers in C++ using array, this program will explain finding the factorial of large number.
31. C++ program to generate random alphabets and store them into a character array.
In this program first we take two character arrays, one to store all the alphabets and other to print random characters into it. To keep it simple we have taken the length as 20.
32. C++ program to print pattern of stars till N number of rows.
This C++ program will read total number of rows from the user and print the star pattern till N rows.
33. C++ Program to print a chessboard pattern.
This C++ program will print a chessboard like pattern using loops.
34. C++ Program to print a Pascal Triangle upto N depth.
This C++ program will read the depth and print the Pascal Trainable up to input depth.
35. C++ program to reverse a number.
This program will read and integer number and print its reverse number in C++.
36. C++ program to sort an array in Descending Order.
This program will read an integer array (one dimensional array) and sort its elements in descending order.
37. C++ program to sort an array in Ascending Order.
This program will read an integer array (one dimensional array) and sort its elements in ascending order.

38. C++ program to convert lowercase character to uppercase and vice versa.
This program will read a character and converts lowercase to uppercase and uppercase to lowercase character.
39. C++ program to check leap year.
This program will read a year from the user and check whether it is Leap year or not.
40. C++ Program to check if a number is even using Recursion.
This program will read a number and check whether it is EVEN or ODD using recursion in C++.
41. C++ Program to find odd or even number without using modulus operator.
This program will read an integer number and check whether it is EVEN or ODD without using Modulus (%) Operator.
42. C++ program to check EVEN or ODD.
This program will read an integer number and check whether it is EVEN or ODD using three different methods.
43. C++ program to add two times.
This program will read two times and calculate their addition (total times in hours, minutes and seconds).
44. C++ program to display prime numbers.
This program will read maximum range of the numbers (N) and print all prime numbers between 2 to N.
45. C++ program to check prime number.
This program will read an integer number and check whether it is Prime or Not using User Defined Function.
46. C++ program to find factorial of a number.
This program will read an integer number and find its factorial using loop and user defined function.
47. C++ program to display name and age.
This program will read name and age of the person and display them on separate lines.
48. C++ program to read a string.
This program will read a string using cin and cin.getline().
49. C++ program to add two integer numbers using class.
This program will read two integer numbers from the user and calculate their addition/sum using class.
50. C++ program to add two integer numbers using pointers.
This program will read two integer numbers from the user and calculate their addition/sum using pointer.
51. C++ program to add two integer numbers using function.
This program will read two integer numbers from the user and calculate their addition/sum using user defined function.
52. C++ program to add two integer numbers.
This program will read two integer numbers from the user and calculate their addition/sum.

TOP Interview Coding Problems/Challenges

 Recommended posts C Tips & Tricks, C++ Tips & Tricks Introduction to Linux (Its modes, Safety, Most popular Applications) Linux Best Distros of 2018 C programming optimization techniques Differences b/w C & Embedded C? Embedded C Interview Q. & A. C programming tips for Embedded Development Basic rules of writing a C program Important points (rules) to remember while writing C/C++ program Top 5 Websites for solving programming challenges Read more...

 Others... Computer G.K. (MCQ) Most viewed pages... Categories...

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8193421,"math_prob":0.8390226,"size":11432,"snap":"2019-13-2019-22","text_gpt3_token_len":2498,"char_repetition_ratio":0.23424922,"word_repetition_ratio":0.2121063,"special_character_ratio":0.2290063,"punctuation_ratio":0.09670131,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.979199,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-03-18T23:49:23Z\",\"WARC-Record-ID\":\"<urn:uuid:394fea86-cde4-4d94-8b0b-f7eadcd783c1>\",\"Content-Length\":\"114298\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9d669acb-bc59-47da-b848-de73013c96ca>\",\"WARC-Concurrent-To\":\"<urn:uuid:c6341e84-7386-49a4-9344-6106ca65c6b6>\",\"WARC-IP-Address\":\"104.27.182.204\",\"WARC-Target-URI\":\"https://www.includehelp.com/cpp-programs/file-handling-examples.aspx\",\"WARC-Payload-Digest\":\"sha1:IYGRPQQTM7VV3NQPINQODTYZZNXZTRNJ\",\"WARC-Block-Digest\":\"sha1:Y2YMSOQD53OVJHUW75UAUN7GJYZZSQKP\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-13/CC-MAIN-2019-13_segments_1552912201812.2_warc_CC-MAIN-20190318232014-20190319014014-00108.warc.gz\"}"}