There is a large text file for my program to read in then output on the screen, is there anyway to point to a character ( including space ) in a text file?
There is a large text file for my program to read in then output on the screen, is there anyway to point to a character ( including space ) in a text file?
>> is there anyway to point to a character...
Depends on what you mean my "point to". There's file position offsets and actual memory pointers.
The file posistion is achieved using tellp() and tellg() members of ostream and istream respectively. The latter is achieved using memory mapped files, which is OS specific.
gg
I mean using a pointer variable to point to the 1st character in the file then keep on pointing till end of file.
That would be the latter, memory mapped files, which is OS specific.
gg
In other words: what OS do you want to do this for?
Perhaps a better question is: Why do you want to do this?
gg
>> why couldn't you use a char * ?
You certainly could.
The most portable implementation of memory mapped files would be to simply allocate enough memory to hold the entire file and load the file into that memory.
gg
I'm not sure why you would want to do this either, but isnt a text character universaly 1 byte?
perhaps I dont fully understand what you mean Eavan. If I do, I dont see why you couldnt use just manipulate the file pointer with seekg and seekp along with char pointers.
Not really ...
The ASCII is one byte char...
but the UNICODE char is two bytes:
sizeof(wchar) == 2