Program 16
#include
#include
#include
int main()
{
#include
int main()
{
std::cin.imbue(std::locale::classic());
std::cout.imbue(std::locale("de_de"));
std::cout.imbue(std::locale("de_de"));
double value;
while (std::cin >> value)
while (std::cin >> value)
{
std::cout << value << std::endl;
}
}
std::cout << value << std::endl;
}
}
Program 17
#include
#include
#include
#include
#include
#include
#include
void writeCharsetInFile(const std::string& filename);
void printFile(const std::string& filename);
int main()
{
try
#include
#include
#include
void writeCharsetInFile(const std::string& filename);
void printFile(const std::string& filename);
int main()
{
try
{
writecharsetinfile("charset.out");
printFile ("charset.out");
}
catch (const std::string& msg)
writecharsetinfile("charset.out");
printFile ("charset.out");
}
catch (const std::string& msg)
{
std::cerr << "Exception: " << msg << std::endl;
return exit_failure;
}
}
void writecharsetinfile(const std::string& filename)
{
std::ofstream file(filename.c_str());
if (! file)
std::cerr << "Exception: " << msg << std::endl;
return exit_failure;
}
}
void writecharsetinfile(const std::string& filename)
{
std::ofstream file(filename.c_str());
if (! file)
{
throw "cannot open file \"" + filename+ "\" for writing";
}
for (int i=32; i<127 i="" nbsp="" span="">127>
throw "cannot open file \"" + filename+ "\" for writing";
}
for (int i=32; i<127 i="" nbsp="" span="">127>
{
file << "value: " << std::setw(3) << i << " "
<< "character: " << static_cast(i) << std::endl;
}
}
void printFile(const std::string& filename)
{
std::ifstream file(filename.c_str());
file << "value: " << std::setw(3) << i << " "
<< "character: " << static_cast
}
}
void printFile(const std::string& filename)
{
std::ifstream file(filename.c_str());
if (! file)
{
throw "cannot open file \"" + filename + "\" for reading";
}
char c;
while (file.get(c))
throw "cannot open file \"" + filename + "\" for reading";
}
char c;
while (file.get(c))
{
std::cout.put(c);
}
}
std::cout.put(c);
}
}
Program 18
#include
#include
#include
#include
using namespace std;
int main (int argc, char* argv[])
{
std::ifstream file;
for (int i=1; i
using namespace std;
int main (int argc, char* argv[])
{
std::ifstream file;
for (int i=1; i
{
file.open(argv[i]);
char c;
while (file.get(c))
file.open(argv[i]);
char c;
while (file.get(c))
{
std::cout.put(c);
}
file.clear();
std::cout.put(c);
}
file.clear();
file.close();
}
}
}
}
Program 19
#include
#include
#include
#include
void printfiletwice(const std::string& filename)
{
char c;
std::ifstream file(filename.c_str());
#include
#include
void printfiletwice(const std::string& filename)
{
char c;
std::ifstream file(filename.c_str());
while (file.get(c))
{
std::cout.put(c);
}
file.clear();
file.seekg(0);
while (file.get(c))
std::cout.put(c);
}
file.clear();
file.seekg(0);
while (file.get(c))
{
std::cout.put(c);
}
}
int main(int argc, char* argv[])
{
std::cout.put(c);
}
}
int main(int argc, char* argv[])
{
for (int i=1; i
{
printfiletwice(argv[i]);
}
}
printfiletwice(argv[i]);
}
}
No comments:
Post a Comment