I'm having trouble using the CreateFile() and WriteFile() functions. Here's the code I've written:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
char cData[6];
DWORD dwBytesWritten;
cout << "Please enter a number: ";
cin >> cData[1];
for(int i = 2; i < 5; i++)
{
cout << "\nPlease enter another number: ";
cin >> cData[i];
}
for(int i = 0; i < 5; i++)
{
cout << cData[i] << endl;
}
HANDLE hFile = CreateFile(TEXT("FileBGP.txt"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
BOOL WriteFile(hFile, &cData, 5, &dwBytesWritten, NULL);
}
The program should allow the user to enter 5 characters/numbers, then write them to a file. However, I get a compile error on BOOL WriteFile() saying this:
error: initializer expression list treated as compound expression
What am I doing wrong here?