Here my C++ code, when I enter string name then its create error and mix the string. kindly help me out. **************** code C++ **************
enter code here
#include <iostream>
using namespace std;
#include <conio.h>
#include <stdio.h>
#include<string>
#include<fstream>
void main()
{
char str[100];
ofstream out("c:\\city.txt");
ifstream in("c:\\city.txt");
for (int i = 0; i < 5; i++)
{
cout << "Enter a string:";
cin>>str;
out << str << "\n";
}
out.close();
cout << "The list of strings is as follows:" << endl;
while (!in.eof())
{
in.getline(str, 100);
cout <<str<<endl;
}
in.close();
system("pause");
}
Aucun commentaire:
Enregistrer un commentaire