|
ifstream is(.....);
CMyClass Class;
do {
is>>Class;
while (!is.eof())
isn't is as good ...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
It won't compile because operator>> doesn't accept a parameter of type CMyClass . Thus, the need to provide the function thus the need to add secured reading
|
|
|
|
|
Disreguard my stupidity and "newbie-ness",
But isnt there a way to translate Binary to text and back to Binary?... Im lost now
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
Yes it could be but I have nothing to do with text... This is not used for printing data to the console but only reading/saving data from/to a file. So I'm just using binary data to load integers, floating, ... values
|
|
|
|
|
didn't you say that you overloaded th operator>>() for it can get a CMyClass parameter to read ?
if you do so, it will compile, and THUS, is will work fine !!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Yes of course, but the question is not there The problem is not reading several CMyClass, the problem is securin the reading of ONE CMyClass
In fact, I want to secure reading the file !
So, this is in the overloaded operator that the checking must be done, not outside. If this file is corrupted (or whatever, something wrong happens) it should throw an exception. So I want to check for end of file (and for other valid parameter) INSIDE the overloaded operator for each member variable of the class.
|
|
|
|
|
ok.
what about :
if (streamObj.eof())
throw CMyEOF;
else {
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Yes, that what I wanted to do but I don't want to check for eof between each member variables (and thus adding this code between each line... a little bit heavy). I think I will read all variables (even if eof is reached in between) and only check for errors at the end of the function.
So to resume, is this flag raised when the last byte of data is read or when you try to read after the last byte ? In the first case, I will throw an exception when I will read the last structure in file even if it completely read (not goooood ). When you try to read data after the eof flag has been raised, is the failed bit raised ? If yes, then I can just check for fail() and raise an exception when it's true.
|
|
|
|
|
i found this in the MSDN at that[^] page :
#include <iostream>
#include <fstream>
int main() {
using namespace std;
fstream file;
file.exceptions(ios::failbit);
try {
file.open("rm.txt", ios_base::in);
}
catch(ios_base::failure f) {
cout << "Caught an exception." << endl;
}
}
i hope this time it will help
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Looks interesting ... I will look at this a little bit more in details, that could be really interesting if an exception is thrown on error
Nowaday, thanks for your help and time. That was an interesting conversation
|
|
|
|
|
it doesn't throw an exception, but it raises a flag you can test with istream::eof()
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
hi:
I can remote debug MFC code thought tcp/ip with VC6 .
But I cann't do it with VC7.
I set the remote IP address in project settins ,and copy msvcmon.exe... to remote PC and run it.
then I press F5,but it didn't work.
Are there have any difference settings?
thanks answer.
|
|
|
|
|
Did you check the network and firewall settings?
Don't try it, just do it!
|
|
|
|
|
Alright... Using fstream when making a simple database using MFC... Say you want to make every letter another letter (coding)... Is it possible?
<br />
void CNewAccountDlg::OnOK() <br />
{<br />
CString strUsername;<br />
CString strPassword;<br />
GetDlgItemText(IDC_USERNAME,strUsername);<br />
GetDlgItemText(IDC_PASSWORD,strPassword);<br />
<br />
ofstream a_file ( "data/account.dat", ios::ate, ios::app);<br />
a_file<< strUsername + " " + strPassword + "\n";<br />
a_file.close();<br />
AfxMessageBox("Account Created.");<br />
}<br />
Nothing wrong with that... Makes a simple file with Username and Password. How could i break my GetDlgItemText into single CHAR allowing me to change them and regroup them back together? Is it possible to break down a String into single Characters?
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
NewbieStats wrote:
GetDlgItemText into single CHAR allowing me to change them?Is it possible to break down a String into single Characters?
Look for CString::GetAt()
NewbieStats wrote:
regroup them back together? Is it possible to break down a String into single Characters?
look at CString::SetAt() ,But beware in this allocate a empty buffer to CString before using CString::SetAt() function
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
Would it be Easier to do that or use;
strPassword.SetSel(0,1); // ++
Copy and Paste to New CString and Add all CStrings together?...
Seems like a long process, but would it be better?
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
|
Okay thanks ill try them both and see which one seems to fit better
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
Hi
I have developed one Multithreading application in C++, which runs on Windows 2000 Professional OS, in which I want to create some 10,000 thread. Is it possible to create these many threads ?
Is there any restriction on how many number of threads can we carete ?
How can I achieve this goal ?
Any suggestion plz...
Thankx a lot
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Why don't you create test application which create 10000 thread!.
as far as I Know MSWord use 1446 threads and Internet Explorer use 1006 thread!!!
PS: these statics may be wrong,as i don't know where i read about this.
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
ThatsAlok wrote:
as far as I Know MSWord use 1446 threads and Internet Explorer use 1006 thread!!!
I'm not sure where you got these numbers, but I've never seen either application use more than a dozen or so each.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
I'm not sure where you got these numbers, but I've never seen either application use more than a dozen or so each.
I remember only one thing I loast computer quiz by not answering this question.really i am no written literature or documentation to comment on above statement
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
As with the above reply, windows does have finite resources and as such does have a maximum limit on the number of threads that it can have. You can do a quick search online in MSDN, but I can bet that it is a lot less .
Personally I think that even thinking of creating 10k threads is a sign of lunacy! , so let us know what you are trying to achieve using your multithreaded app, and we'll do our best to find a more reasonable alternative design.
I Dream of Absolute Zero
|
|
|
|
|
Hi RChin,
Thanks a lot to reply me, and be glad that u show interest.
I m developing a Windows service that is going to monitor something around 5000 mailboxes and my requirement is such that i want to get new mails as it appears in any of mail box with minimum time delay.
Any design or coding suggestions will be highly appreciated.
Thanks in advance.
Mahesh.
|
|
|
|
|
The need for so many threads is an indication of a design flaw. While it may be possible (I do not know the maximum count), switching between the threads, or even searching the list of threads, will have a serious impact on performance. Remember that a multi-threaded application, unless run on a multiprocessor machine, can be slower than its single-threaded counterpart simply because of all the context switching that must go on.
See here, here, and here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|