473,714 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem reading a bin file

Hi,

I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.

I need to insert new features to an old program that I wrote in delphi
and it's a good opportunity to start with c++.
well, the problem is:

I need to read a binary file according to some structure, all
variables of its structure are of type "char" of different sizes.

The reading is made ok, but the value that I got of ManVer is his
value concatenated with Pieces and Weight and WeightUnit, the value of
Pieces is his value and also concatenated with Weight and WeightUnit.
This happens with the rest of variables until the last of them, that
only has his value.

Only when I see the structure with Evaluate/Modify (Ctrl +F7 on
windows) the result is the one that I expect to get

I hope that you can help me...
here's the code:
--------------

ifstream _fileStream;
TStructure_V250 _Data _buffer250;

//open the file...
char* _fName = new char[_fileName.Lengt h() +1];
strcpy(_fName, _fileName.c_str ());

_fileStream.ope n(_fName, ios::binary);
delete [] _fName;
//read data...
_fileStream.rea d((char*)&_buff er250, sizeof(_buffer2 50));

---------------------------
_buffer250 structure is too long, i only show you a piece
---------------------------
typedef struct _Structure_V250 _Data
{
char ManVer[4];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
//...
//...
//...
} TStructure_V250 _Data;
Dec 23 '07 #1
6 3527
"efrenba" <ef*****@gmail. comwrote in message
news:d2******** *************** ***********@d21 g2000prf.google groups.com...
Hi,

I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.

I need to insert new features to an old program that I wrote in delphi
and it's a good opportunity to start with c++.
well, the problem is:

I need to read a binary file according to some structure, all
variables of its structure are of type "char" of different sizes.

The reading is made ok, but the value that I got of ManVer is his
value concatenated with Pieces and Weight and WeightUnit, the value of
Pieces is his value and also concatenated with Weight and WeightUnit.
This happens with the rest of variables until the last of them, that
only has his value.

Only when I see the structure with Evaluate/Modify (Ctrl +F7 on
windows) the result is the one that I expect to get

I hope that you can help me...
here's the code:
--------------

ifstream _fileStream;
TStructure_V250 _Data _buffer250;

//open the file...
char* _fName = new char[_fileName.Lengt h() +1];
strcpy(_fName, _fileName.c_str ());

_fileStream.ope n(_fName, ios::binary);
delete [] _fName;
//read data...
_fileStream.rea d((char*)&_buff er250, sizeof(_buffer2 50));

---------------------------
_buffer250 structure is too long, i only show you a piece
---------------------------
typedef struct _Structure_V250 _Data
{
char ManVer[4];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
//...
//...
//...
} TStructure_V250 _Data;
Whatever you are using to display the first string is expecting a nul
terminated string. If you don't have a nul at the end of ManVer your
display function keeps going through memory until it finds a nul, no matter
how far it has to go. (This often results in an access violation.) So it
seems the program is working but you are not interpreting or displaying the
results correctly.

Do not attempt to display char strings that do not have a nul termination.

--
Scott McPhillips [VC++ MVP]

Dec 23 '07 #2
On Dec 22, 11:21 pm, efrenba <efre...@gmail. comwrote:
Hi,

I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.

I need to insert new features to an old program that I wrote in delphi
and it's a good opportunity to start with c++.

well, the problem is:

I need to read a binary file according to some structure, all
variables of its structure are of type "char" of different sizes.

The reading is made ok, but the value that I got of ManVer is his
value concatenated with Pieces and Weight and WeightUnit, the value of
Pieces is his value and also concatenated with Weight and WeightUnit.
This happens with the rest of variables until the last of them, that
only has his value.

Only when I see the structure with Evaluate/Modify (Ctrl +F7 on
windows) the result is the one that I expect to get

I hope that you can help me...

here's the code:
--------------

ifstream _fileStream;
TStructure_V250 _Data _buffer250;

//open the file...
char* _fName = new char[_fileName.Lengt h() +1];
strcpy(_fName, _fileName.c_str ());

_fileStream.ope n(_fName, ios::binary);
delete [] _fName;

//read data...
_fileStream.rea d((char*)&_buff er250, sizeof(_buffer2 50));

---------------------------
_buffer250 structure is too long, i only show you a piece
---------------------------
typedef struct _Structure_V250 _Data
{
char ManVer[4];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
//...
//...
//...

} TStructure_V250 _Data;

Have you considered trying a different angle? Instead of storing data
in binary, why not store records with members seperated by spaces. If
you were to organize your class members with std::strings, integers,
doubles or whatever, then you could use operator<< and operator>to
stream your data in/out. you would use std::ifstream and std::getline
to extract your records, one line at a time, into a
std::vector<Som eTypeand use the operators to have the class stream
in your data (and therefore construct instances of that class).

The problem from our point of view is we just don't know what ManVer
represents. Is it a player, a person? Instead of having everything be
a char, why not deal with primitive types and strings as what they
really are instead of characters? Why not deal with a type instead of
a binary soup?

You'll probably say "i'ld rather not redesign the whole system from
scratch" but then thats the problem, isn't it? You have code that
isn't easily modifyable, let alone extendeable, without a considerable
amount of work. You don't have to live that life. There is a better
way.

Give us an idea of what the struct is meant to represent. What is a
ManVer?
Dec 23 '07 #3
On Dec 23, 2:17 am, Salt_Peter <pj_h...@yahoo. comwrote:
On Dec 22, 11:21 pm, efrenba <efre...@gmail. comwrote:
Hi,
I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.
I need to insert new features to an old program that I wrote in delphi
and it's a good opportunity to start with c++.
well, the problem is:
I need to read a binary file according to some structure, all
variables of its structure are of type "char" of different sizes.
The reading is made ok, but the value that I got of ManVer is his
value concatenated with Pieces and Weight and WeightUnit, the value of
Pieces is his value and also concatenated with Weight and WeightUnit.
This happens with the rest of variables until the last of them, that
only has his value.
Only when I see the structure with Evaluate/Modify (Ctrl +F7 on
windows) the result is the one that I expect to get
I hope that you can help me...
here's the code:
--------------
ifstream _fileStream;
TStructure_V250 _Data _buffer250;
//open the file...
char* _fName = new char[_fileName.Lengt h() +1];
strcpy(_fName, _fileName.c_str ());
_fileStream.ope n(_fName, ios::binary);
delete [] _fName;
//read data...
_fileStream.rea d((char*)&_buff er250, sizeof(_buffer2 50));
---------------------------
_buffer250 structure is too long, i only show you a piece
---------------------------
typedef struct _Structure_V250 _Data
{
char ManVer[4];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
//...
//...
//...
} TStructure_V250 _Data;

Have you considered trying a different angle? Instead of storing data
in binary, why not store records with members seperated by spaces. If
you were to organize your class members with std::strings, integers,
doubles or whatever, then you could use operator<< and operator>to
stream your data in/out. you would use std::ifstream and std::getline
to extract your records, one line at a time, into a
std::vector<Som eTypeand use the operators to have the class stream
in your data (and therefore construct instances of that class).

The problem from our point of view is we just don't know what ManVer
represents. Is it a player, a person? Instead of having everything be
a char, why not deal with primitive types and strings as what they
really are instead of characters? Why not deal with a type instead of
a binary soup?

You'll probably say "i'ld rather not redesign the whole system from
scratch" but then thats the problem, isn't it? You have code that
isn't easily modifyable, let alone extendeable, without a considerable
amount of work. You don't have to live that life. There is a better
way.

Give us an idea of what the struct is meant to represent. What is a
ManVer?


Hi,

Unfortunately I cann't change the file structure because it belongs to
a wide system around the world. This system runs over unix os and has
several years online.

The reason that I wrote this application for the first time in delphi
is because we needed an interface that was capable to read those files
and to generate more friendly reports to analyze several situations at
work.

Extracted from a pdf sent by the company:
--------------------------------------------
variables file offset type values
-------------------------------------------------------
char ManVer[4]; //1-4 4AN 250U or 260U (data
struct version)
char Filler1[3]; //5-7 3AN SYS Reserved
char Pieces[3]; //8-10 3N Qty
char Weight[5]; //11-15 5.2D Some value
char WeightUnit[2]; //16-17 2A KG or LB, etc
char Orig_ProcHub[3]; //18-20 3A Origin
char FlightDest[3]; //21-23 3A Destiny
char PrintFlag; //24 1AN SYS Reserved
....
....
until 71 variables
A = Alphabetic, left-justified, blank-filled
AN = Alphanumeric, left justified, blank-filled
D = Decimal, right-justified, zero-filled (for example, 4.1D denotes
one implied decimal in a 4-digit string)
N = Numeric, right justified, zero-filled
I don't understand, why when the reading is made, the nul char is not
set and the end of each variables?

Also I have other doubt, if I change the size of each variables to set
the nul character at the end, the reading won't be made ok.
I need help... Thanks for your time...
Dec 23 '07 #4
efrenba wrote:
On Dec 23, 2:17 am, Salt_Peter <pj_h...@yahoo. comwrote:
>On Dec 22, 11:21 pm, efrenba <efre...@gmail. comwrote:
>>Hi,
>>I came from delphi world and now I'm doing my first steps in C++.
I'm using C++builder because its ide is like delphi although I'm
trying to avoid the vcl.
>>I need to insert new features to an old program that I wrote in
delphi and it's a good opportunity to start with c++.
>>well, the problem is:
>>I need to read a binary file according to some structure, all
variables of its structure are of type "char" of different sizes.
>>The reading is made ok, but the value that I got of ManVer is his
value concatenated with Pieces and Weight and WeightUnit, the value
of Pieces is his value and also concatenated with Weight and
WeightUnit. This happens with the rest of variables until the last
of them, that only has his value.
>>Only when I see the structure with Evaluate/Modify (Ctrl +F7 on
windows) the result is the one that I expect to get
>>I hope that you can help me...
>>here's the code:
--------------
>>ifstream _fileStream;
TStructure_V2 50_Data _buffer250;
>>//open the file...
char* _fName = new char[_fileName.Lengt h() +1];
strcpy(_fName , _fileName.c_str ());
>>_fileStream.o pen(_fName, ios::binary);
delete [] _fName;
>>//read data...
_fileStream.r ead((char*)&_bu ffer250, sizeof(_buffer2 50));
>>---------------------------
_buffer250 structure is too long, i only show you a piece
---------------------------
typedef struct _Structure_V250 _Data
{
char ManVer[4];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
//...
//...
//...
>>} TStructure_V250 _Data;

Have you considered trying a different angle? Instead of storing data
in binary, why not store records with members seperated by spaces. If
you were to organize your class members with std::strings, integers,
doubles or whatever, then you could use operator<< and operator>to
stream your data in/out. you would use std::ifstream and std::getline
to extract your records, one line at a time, into a
std::vector<So meTypeand use the operators to have the class stream
in your data (and therefore construct instances of that class).

The problem from our point of view is we just don't know what ManVer
represents. Is it a player, a person? Instead of having everything be
a char, why not deal with primitive types and strings as what they
really are instead of characters? Why not deal with a type instead of
a binary soup?

You'll probably say "i'ld rather not redesign the whole system from
scratch" but then thats the problem, isn't it? You have code that
isn't easily modifyable, let alone extendeable, without a
considerable amount of work. You don't have to live that life. There
is a better way.

Give us an idea of what the struct is meant to represent. What is a
ManVer?



Hi,

Unfortunately I cann't change the file structure because it belongs to
a wide system around the world. This system runs over unix os and has
several years online.

The reason that I wrote this application for the first time in delphi
is because we needed an interface that was capable to read those files
and to generate more friendly reports to analyze several situations at
work.

Extracted from a pdf sent by the company:
--------------------------------------------
variables file offset type values
-------------------------------------------------------
char ManVer[4]; //1-4 4AN 250U or 260U (data
struct version)
char Filler1[3]; //5-7 3AN SYS Reserved
char Pieces[3]; //8-10 3N Qty
char Weight[5]; //11-15 5.2D Some value
char WeightUnit[2]; //16-17 2A KG or LB, etc
char Orig_ProcHub[3]; //18-20 3A Origin
char FlightDest[3]; //21-23 3A Destiny
char PrintFlag; //24 1AN SYS Reserved
...
...
until 71 variables
A = Alphabetic, left-justified, blank-filled
AN = Alphanumeric, left justified, blank-filled
D = Decimal, right-justified, zero-filled (for example, 4.1D denotes
one implied decimal in a 4-digit string)
N = Numeric, right justified, zero-filled
I don't understand, why when the reading is made, the nul char is not
set and the end of each variables?

Also I have other doubt, if I change the size of each variables to set
the nul character at the end, the reading won't be made ok.
I need help... Thanks for your time...
Okay, here's the issue. Lets take for example the first three values in the
file.

char ManVer[4]; //1-4 4AN 250U or 260U (data
struct version)
char Filler1[3]; //5-7 3AN SYS Reserved
char Pieces[3]; //8-10 3N Qty

Now, the actual data in the file may look something like this:

2AXXX023...

Reading this into your structure it should put the characters into the right
fields, that is.

ManVer should contain the characters ' ' ' ' '2' 'A'
You really need to add a filler field to take up the next three chars, but
then
Pieces would contain '0' '2' '3'.

Notice, howiever, ManVer does NOT contain " 2A" because that indicates a
null terminated string. The file spec says that the fields are not null
terminated. Meaning you can not treat these as any type of c-style or c++
style strings as they sit. You could look at each individual character to
see what they contain.. I.E. something like

for ( int size_t i = 0; i < sizeof ManVer; ++i )
std::cout << ManVer[i];
std::cout << "\n";

Now, you really can't put space for a null terminator in your structure and
read the file directly into your structure because there is no room in the
file. For you to do anything with the fields you'll need to convert them to
a c or c++ style string or a number. There's a few ways to do that, using
strncpy with c-style strings, adding chars or using a std::string
constructor with std::string (I *think* there is a std::string constructor
taking iterators to the first and last char to add, not sure).

You are doing fine now, as long as you have the fields in your structure
correctly mapped to the fields in the flat file. Make sure you put in space
for that filler.

But now your problem becomes what to do with the fields. This is up to you.
You can continue to treat them as pure characters without null terminators
throughout your program, or you can convert the fields you need as you need
them, or you could convert them all to proper c++ variables after you read
them.

Here is a little program I threw together showing one way they could be
converted. This is just one of many ways you could do it and the best way
is up for you to decide.

Output of the program is:

ManVer: 2a
Pieces: 2
Weight: 4.6

#include <string>
#include <iostream>
#include <sstream>

struct TStructure_V250 _Data
{
char ManVer[4];
char Filler[3];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
/* etc... */
};

void PretendtoRead( TStructure_V250 _Data& Data )
{
std::strncpy( Data.ManVer, " 2a", 4 );
std::strncpy( Data.Filler, "xxx", 3 );
std::strncpy( Data.Pieces, "002", 3 );
std::strncpy( Data.Weight, "00460", 5 );
std::strncpy( Data.WeightUnit , "KG", 2 );
}

std::string CharsToString( const char* Input, int Length )
{
return std::string(Inp ut, &Input[Length] );
}

int main()
{
TStructure_V250 _Data Data;
PretendtoRead( Data );

std::cout << "ManVer: " << CharsToString( Data.ManVer, sizeof
Data.ManVer ) << "\n";

int Pieces;
std::stringstre am Convert;
Convert << CharsToString( Data.Pieces, sizeof Data.Pieces );
Convert >Pieces;
std::cout << "Pieces: " << Pieces << "\n";

double Weight = 0.0f;
Convert.clear() ;
Convert << Data.Weight;
Convert >Weight;
Weight /= 100;
std::cout << "Weight: " << Weight << "\n";
}
--
Jim Langston
ta*******@rocke tmail.com
Dec 23 '07 #5
On Dec 23, 6:22 pm, "Jim Langston" <tazmas...@rock etmail.comwrote :
efrenba wrote:
On Dec 23, 2:17 am, Salt_Peter <pj_h...@yahoo. comwrote:
On Dec 22, 11:21 pm, efrenba <efre...@gmail. comwrote:
>Hi,
>I came from delphi world and now I'm doing my first steps in C++.
I'm using C++builder because its ide is like delphi although I'm
trying to avoid the vcl.
>I need to insert new features to an old program that I wrote in
delphi and it's a good opportunity to start with c++.
>well, the problem is:
>I need to read a binary file according to some structure, all
variables of its structure are of type "char" of different sizes.
>The reading is made ok, but the value that I got of ManVer is his
value concatenated with Pieces and Weight and WeightUnit, the value
of Pieces is his value and also concatenated with Weight and
WeightUnit. This happens with the rest of variables until the last
of them, that only has his value.
>Only when I see the structure with Evaluate/Modify (Ctrl +F7 on
windows) the result is the one that I expect to get
>I hope that you can help me...
>here's the code:
--------------
>ifstream _fileStream;
TStructure_V25 0_Data _buffer250;
>//open the file...
char* _fName = new char[_fileName.Lengt h() +1];
strcpy(_fNam e, _fileName.c_str ());
>_fileStream.op en(_fName, ios::binary);
delete [] _fName;
>//read data...
_fileStream.re ad((char*)&_buf fer250, sizeof(_buffer2 50));
>---------------------------
_buffer250 structure is too long, i only show you a piece
---------------------------
typedef struct _Structure_V250 _Data
{
char ManVer[4];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
//...
//...
//...
>} TStructure_V250 _Data;
Have you considered trying a different angle? Instead of storing data
in binary, why not store records with members seperated by spaces. If
you were to organize your class members with std::strings, integers,
doubles or whatever, then you could use operator<< and operator>to
stream your data in/out. you would use std::ifstream and std::getline
to extract your records, one line at a time, into a
std::vector<Som eTypeand use the operators to have the class stream
in your data (and therefore construct instances of that class).
The problem from our point of view is we just don't know what ManVer
represents. Is it a player, a person? Instead of having everything be
a char, why not deal with primitive types and strings as what they
really are instead of characters? Why not deal with a type instead of
a binary soup?
You'll probably say "i'ld rather not redesign the whole system from
scratch" but then thats the problem, isn't it? You have code that
isn't easily modifyable, let alone extendeable, without a
considerable amount of work. You don't have to live that life. There
is a better way.
Give us an idea of what the struct is meant to represent. What is a
ManVer?
Hi,
Unfortunately I cann't change the file structure because it belongs to
a wide system around the world. This system runs over unix os and has
several years online.
The reason that I wrote this application for the first time in delphi
is because we needed an interface that was capable to read those files
and to generate more friendly reports to analyze several situations at
work.
Extracted from a pdf sent by the company:
--------------------------------------------
variables file offset type values
-------------------------------------------------------
char ManVer[4]; //1-4 4AN 250U or 260U (data
struct version)
char Filler1[3]; //5-7 3AN SYS Reserved
char Pieces[3]; //8-10 3N Qty
char Weight[5]; //11-15 5.2D Some value
char WeightUnit[2]; //16-17 2A KG or LB, etc
char Orig_ProcHub[3]; //18-20 3A Origin
char FlightDest[3]; //21-23 3A Destiny
char PrintFlag; //24 1AN SYS Reserved
...
...
until 71 variables
A = Alphabetic, left-justified, blank-filled
AN = Alphanumeric, left justified, blank-filled
D = Decimal, right-justified, zero-filled (for example, 4.1D denotes
one implied decimal in a 4-digit string)
N = Numeric, right justified, zero-filled
I don't understand, why when the reading is made, the nul char is not
set and the end of each variables?
Also I have other doubt, if I change the size of each variables to set
the nul character at the end, the reading won't be made ok.
I need help... Thanks for your time...

Okay, here's the issue. Lets take for example the first three values in the
file.

char ManVer[4]; //1-4 4AN 250U or 260U (data
struct version)
char Filler1[3]; //5-7 3AN SYS Reserved
char Pieces[3]; //8-10 3N Qty

Now, the actual data in the file may look something like this:

2AXXX023...

Reading this into your structure it should put the characters into the right
fields, that is.

ManVer should contain the characters ' ' ' ' '2' 'A'
You really need to add a filler field to take up the next three chars, but
then
Pieces would contain '0' '2' '3'.

Notice, howiever, ManVer does NOT contain " 2A" because that indicates a
null terminated string. The file spec says that the fields are not null
terminated. Meaning you can not treat these as any type of c-style or c++
style strings as they sit. You could look at each individual character to
see what they contain.. I.E. something like

for ( int size_t i = 0; i < sizeof ManVer; ++i )
std::cout << ManVer[i];
std::cout << "\n";

Now, you really can't put space for a null terminator in your structure and
read the file directly into your structure because there is no room in the
file. For you to do anything with the fields you'll need to convert them to
a c or c++ style string or a number. There's a few ways to do that, using
strncpy with c-style strings, adding chars or using a std::string
constructor with std::string (I *think* there is a std::string constructor
taking iterators to the first and last char to add, not sure).

You are doing fine now, as long as you have the fields in your structure
correctly mapped to the fields in the flat file. Make sure you put in space
for that filler.

But now your problem becomes what to do with the fields. This is up to you.
You can continue to treat them as pure characters without null terminators
throughout your program, or you can convert the fields you need as you need
them, or you could convert them all to proper c++ variables after you read
them.

Here is a little program I threw together showing one way they could be
converted. This is just one of many ways you could do it and the best way
is up for you to decide.

Output of the program is:

ManVer: 2a
Pieces: 2
Weight: 4.6

#include <string>
#include <iostream>
#include <sstream>

struct TStructure_V250 _Data
{
char ManVer[4];
char Filler[3];
char Pieces[3];
char Weight[5];
char WeightUnit[2];
/* etc... */

};

void PretendtoRead( TStructure_V250 _Data& Data )
{
std::strncpy( Data.ManVer, " 2a", 4 );
std::strncpy( Data.Filler, "xxx", 3 );
std::strncpy( Data.Pieces, "002", 3 );
std::strncpy( Data.Weight, "00460", 5 );
std::strncpy( Data.WeightUnit , "KG", 2 );

}

std::string CharsToString( const char* Input, int Length )
{
return std::string(Inp ut, &Input[Length] );

}

int main()
{
TStructure_V250 _Data Data;
PretendtoRead( Data );

std::cout << "ManVer: " << CharsToString( Data.ManVer, sizeof
Data.ManVer ) << "\n";

int Pieces;
std::stringstre am Convert;
Convert << CharsToString( Data.Pieces, sizeof Data.Pieces );
Convert >Pieces;
std::cout << "Pieces: " << Pieces << "\n";

double Weight = 0.0f;
Convert.clear() ;
Convert << Data.Weight;
Convert >Weight;
Weight /= 100;
std::cout << "Weight: " << Weight << "\n";

}

--
Jim Langston
tazmas...@rocke tmail.com
Thanks to all, for your time, I will continue studying C++, 'cause it
seems to be that this language is not easy...

Dec 24 '07 #6
On Dec 23, 5:21 pm, efrenba <efre...@gmail. comwrote:
>
//open the file...
char* _fName = new char[_fileName.Lengt h() +1];
strcpy(_fName, _fileName.c_str ());

_fileStream.ope n(_fName, ios::binary);
delete [] _fName;
You can replace all of that with:

_fileStream.ope n( _fileName.c_str (), ios::binary );

Also, in C++ it is not good to start identifiers with
the underscore (those names could be reserved to the
implementation. Better is just 'fileName', or if you
must, 'fileName_' .
Dec 25 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7053
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the file... Thank you to all of you who can help me with this one...
8
9852
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out | ios::binary) to declare a file object with read/write modes turned on for working with binary data. I've tried this and my file is not created. The only time it is created is when I specify ifstream or ofstream but not fstream. I've tried removing the...
1
2577
by: Magnus Lycka | last post by:
I'm trying to read standard out in a process started with popen2 in a non-blocking way. (Other good ways of doing this than the one I tried are appreciated.) I've tried to dumb down my code to see what happens, and socket.poll seems to behave very strangely. I've tried to use the .poll method for the poll object with and without a timeout, but in either case, the output randomly switches between on of the versions below. It runs fast,...
7
5447
by: Thomas Sourmail | last post by:
Hi, I hope I am missing something simple, but.. here is my problem: I need my program to check the last column of a file, as in : a b c d target ref 0 0 0 0 1 a 1 0 0 0 1.5 b 2 0 0 0 2 c
2
2492
by: Sabin Finateanu | last post by:
Hi I'm having problem reading a file from my program and I think it's from a procedure I'm using but I don't see where I'm going wrong. Here is the code: public bool AllowUsage() { OperatingSystem os = Environment.OSVersion; AppDomain ad = Thread.GetDomain();
0
3937
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
0
1762
by: Fabrice | last post by:
Hello, (Alain) Tis is a part of my code to retrieve text from hastable in memory cache, by reading (befor) a resources file. Thanks for your help. /1/ The resources file * I have create a .TXT file with Keys/Values
5
14988
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing and why I have to do it. Hopefully someone has a suggestion... Alright, so I'm using a gps-simulation program that outputs gps data, like longitude, lattitude, altitude, etc. (hundreds of terms, these are just the well known ones). In the newer...
10
2197
by: oktayarslan | last post by:
Hi all; I have a problem when inserting an element to a vector. All I want is reading some data from a file and putting them into a vector. But the program is crashing after pushing a data which has string value. I really do not understand why push_back() function is trying to remove previously inserted data. Thanks for any help
0
8706
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7947
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6632
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2518
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2108
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.