-
Re: fstream on Irix
* Mark Hellegers <M.H.Hellegers@stud.tue.nl>
| According to the man page for fstream, there should be some
| functions to do this. If I read it correctly there should be an
| attach function and the constructor to do this, but this doesn't
| work. The compiler says they don't exist and the fstream header
| indeed does not have these functions.
IIUC iostream::attach is no longer in the C++ Standard.
This works for me w/o attach:
int fd = open("foo", O_RDONLY);
if (fd < 0) {
perror("open");
} else {
ifstream fstr(fd);
// demo only, caveat buffer overflows!
char buffer[1024];
fstr >> buffer;
printf("buffer '%s'\n", buffer);
}
R'
-
Re: fstream on Irix
In message <ygahe4uu6hz.fsf@jupiter.akutech-local.de>, Ralf Fassel wrote:[color=blue]
> * Mark Hellegers <M.H.Hellegers@stud.tue.nl>
> | According to the man page for fstream, there should be some
> | functions to do this. If I read it correctly there should be an
> | attach function and the constructor to do this, but this doesn't
> | work. The compiler says they don't exist and the fstream header
> | indeed does not have these functions.
>
> IIUC iostream::attach is no longer in the C++ Standard.
> This works for me w/o attach:
>
> int fd = open("foo", O_RDONLY);
> if (fd < 0) {
> perror("open");
> } else {
> ifstream fstr(fd);
>
> // demo only, caveat buffer overflows!
> char buffer[1024];
> fstr >> buffer;
> printf("buffer '%s'\n", buffer);
> }[/color]
Hmm, this isn't working here. What compiler are you using ?
I should have mentioned this in the initial post, but I'm using the MipsPro 7.3
compiler.
I'm getting this error message:
cc-1262 CC: ERROR File = BinaryFile.cpp, Line = 26
No instance of constructor
"std::basic_ifstream<char, std::char_traits<char>>::basic_ifstream"
matches the argument list.
The argument types are: (int).
ifstream object( fd );
Mark