Re: writing binary file (ios::binary)
On Apr 25, 7:45 pm, Erik Wikstr=F6m <Erik-wikst...@telia.com> wrote:
On 2008-04-25 18:40, Ron Eggler wrote:
I would like to write binary data in a file i open
(ofstream) with ios::binary but it keeps failing and it
gives me a segmentation fault. What I'm exactly doing:
[C++]
if (isBinary == true)
{
std::cout << "open(" << filename.c_str() << ", std::ios:=
:binary |
std::ios::trunc);" << std::endl;
ofs->open(filename.c_str(), std::ios::binary | std::ios:=
:trunc);
}
[/C++]
And the output on my shell(as root) looks like:
[shell]
Filename: /root/PRS_UPDATE/prs
open(/root/PRS_UPDATE/prs, std::ios::binary | std::ios::trunc);
Segmentation fault (core dumped)
[/shell]
The permissions of folder /root/PRS_UPDATE look like:
root@NovaxPRG-T1111:~/src/updater/build# ls -la /root/PRS_UPDATE/
total 8
drwxrwxrwx 2 reg users 4096 2008-04-25 09:10 .
drwxr-xr-x 10 root root 4096 2008-04-25 09:10 ..
I'm not understanding, anyone an idea where the problem
could be? Any suggestions are highly appreciated!
No idea, but compiling the program with debug symbols and
starting it in gdb will help you figure it out.
Before doing that, I'd ask what ofs points to. Until you've
answered that question, there's no point in the debugger (and
once you've answered it, you've probably already solved the
problem).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34