Okie, em hiểu và làm được rồi ^ ^. Nhưng lại có 1 đống ký tự trắng phía sau, em nghĩ là do những phần tử dư của mảng tạo nên.
Code:
#include <iostream>
#include <fstream>
using namespace std;
const int A = 100;
void main()
{
char a[A] = {0};
ifstream in;
in.open("input.txt", ios::in | ios::binary);
if(!in)
exit(1);
in.read(a, sizeof(a));
ofstream out;
out.open("ouput.txt", ios::out | ios::binary);
if(!out)
exit(1);
out.write(a, sizeof(a));
out.close();
}
Nên em đã dùng mảng động để không có khoảng trắng dư, và ... nó chỉ hiện 1 chữ đầu tiên trong chuỗi(nghĩa là gặp khoảng trắng thì nó kết thúc vệc ghi). (Có lẽ bây giờ không hiểu nhưng mai mốt sẽ hiểu ^ ^)
Code:
#include <iostream>
#include <fstream>
using namespace std;
const int A = 5;
void main()
{
char *a = new char[A];
for(int i = 0; i < A; i++)
*(a + i) = 0;
ifstream in;
in.open("input.txt", ios::in | ios::binary);
if(!in)
exit(1);
in.read(a, sizeof(a));
ofstream out;
out.open("ouput.txt", ios::out | ios::binary);
if(!out)
exit(1);
out.write(a, sizeof(a));
out.close();
delete[] a;
}