1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#include <iostream>
#include <fstream>
using namespace std;
// Int, char, double och functions
int antBilar;
char bilTyp[100];
int bilKW;
int x;
void filter();
void binaryWrite();
wchar_t * str = L"Volvo";
// Int, char, double och functions
void filter()
{
cout << "Antal bilar: ";
cin >> antBilar;
int i;
while(x < antBilar)
{
cout << "Bilnamn #" << x+1 << endl;
x++;
}
}
void binaryWrite()
{
ofstream file("C:\\Users\\Bosse\\Desktop\\test.flt", ios::out | ios::binary | ios::app);
if (file.good())
{
char buf[5] = {254, 255, 255, 255, 1};
char buf2[7] = {1, 0, 3, 0, 0, 0, 0};
char bilNamn[94] = {68, 88, 85, 70, 77, 84, 0, 4, 0, 0, 0, 65, 0, 117, 0,
100, 0, 105, 0, 2, 0, 0, 0, 33, 0, 0, 0, 86, 0, 101, 0, 104, 0, 105, 0, 99, 0,
108, 0, 101, 0, 84, 0, 121, 0, 112, 0, 101, 0, 71, 0, 114, 0, 105, 0, 100, 0,
68, 0, 66, 0, 84, 0, 97, 0, 98, 0, 108, 0, 101, 0, 86, 0, 105, 0, 101, 0, 119,
0, 109, 0, 97, 0, 110, 0, 78, 0, 97, 0, 109, 0, 101, 0, 18};
file.write(buf, sizeof(buf));
file.write((char*)&antBilar, sizeof(antBilar));
file.write(buf2, sizeof(buf2));
file.write(bilNamn, sizeof(bilNamn));
file.write((char*)str, wcslen(str) * sizeof(wchar_t));
file.write((char*)str, wcslen(str) * sizeof(wchar_t));
file.close();
}
}
int main()
{
filter();
binaryWrite();
}
|