0% found this document useful (0 votes)
4 views2 pages

CPP File1

The document is a C++ program that allows users to input characters and strings, which are then written to separate text files ('char.txt' and 'string.txt'). It prompts the user to continue entering data until they choose to stop, and then reads back the contents of the files to display the entered data. The program utilizes file input and output streams for handling character and string data.

Uploaded by

amirsohail19375
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

CPP File1

The document is a C++ program that allows users to input characters and strings, which are then written to separate text files ('char.txt' and 'string.txt'). It prompts the user to continue entering data until they choose to stop, and then reads back the contents of the files to display the entered data. The program utilizes file input and output streams for handling character and string data.

Uploaded by

amirsohail19375
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include<iostream>

#include<fstream>

using namespace std;

int main()

char str[20],ch,op;

ifstream in;

ofstream out;

// for characters

[Link]("[Link]");

do

cout<<"\n enter some character to write into the file::";

cin>>ch;

[Link](ch);

cout<<"\n continue enter y/Y::";

cin>>op;

}while(op=='y'||op=='Y');

[Link]();

[Link]("[Link]");

cout<<"\n entered characters are as follows\n";

while([Link](ch))

putchar(ch);

[Link]();

//for strings

[Link]("[Link]");
do

cout<<"\n enter some string to write into the file::";

cin>>str;

[Link]((char *)str,sizeof(str));

out<<"\n";

cout<<"\n continue enter y/Y::";

cin>>op;

}while(op=='y'||op=='Y');

[Link]();

[Link]("[Link]");

cout<<"\n entered characters are as follows\n";

while([Link]((char *)str,sizeof(str)))

puts(str);

[Link]();

return 0;

You might also like