i know how to read a file into array, however i want to perform some search operations which is difficult to do on array.
if someway i am able to read a file to string then it becomes easier. i have 2 methods of reading a file into wstring but i don't get all the contents of a file. the file reading is stopped upon the occurence of first null character. how can i stop this from happening?
please note that i am reading a file that consits of all characters (ascii 0-255) therefore i must use wstring instead of string..
here is what i have tried so far..
#include <sstream>
#include <fstream>
#include<iostream>
using namespace std;
wstring readfile(const char* filename)
{
wifstream wif(filename,ios::binary);
wstringstream wss;
wss << wif.rdbuf();
return wss.str();
//is there a way i can perform search operations on rdbuf()?
}
void main()
{
wstring wstr = readfile("hello.exe");
wcout<<wstr;//here i get less than 10 characters, while file consists of 200 bytes =(
}