|
PJ Arends wrote: The version of STL that came with VC6 would overwhelm you with warnings, but later versions have fixed that.
True.
As mentioned earlier, this particular warning is level 3 though in VS2K5 .
|
|
|
|
|
prasad_som wrote: But it is not recommended to this level. As, warnings though this level can be safely ignored.
I don't think that an implicit conversion from double to int should be ever safely ignored.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Yes. I was refering to level 4 warnings. As you can see my further posts about this particular warning. Should be treated as level 3 warning and it is level 3 warning in VS2k5 .
|
|
|
|
|
I used a COleDateTime variant and also has initialized it, but when I want to store it in a CString object, using the Format(...) function,there would be some wrong: it refuse to work!.
somebody would tell me why,and how to resolve it?
Thanks Very Much!
|
|
|
|
|
It seems to work for me. Try this:
COleDateTime dt(1971, 6, 12, 12, 0, 0);
CString s = dt.Format();
AfxMessageBox(s);
Steve
|
|
|
|
|
Can you show code, what you are trying ?
|
|
|
|
|
COleDateTime time(1996,1,1,0,0,0);
int status=time.GetStatus();
cout<
|
|
|
|
|
kcynic wrote: str=time.Format("%Y %m %d %H:%M:%S");//Wrong
Whats wrong here ? I can see its formating time , as it should.
i.e. "1996 01 01 00:00:00"
|
|
|
|
|
I have created a class file and class header- in the header I save version,file name, and # of last file saved
then everything after that is the file storage.. The problem I am having is: my index has a bug-
reading the file:
file k[150];
header hdrs;
ifstream op("file.dat",ios::nocreate);
op.read(reinterpret_cast <char*> (&hdrs),sizeof(header));
op.read(reinterpret_cast <char*> (&k),hdrs.index * sizeof(file));
saving the file:
strcpy(k[hdrs.index].first_name,s);
m_last.GetWindowText(f);
strcpy(k[hdrs.index].last_name,f);
ofstream fi("file.dat",ios::nocreate);
if(!fi.is_open())
{
MessageBox("File failed!","",MB_OK);
}
hdrs.index++;
s.Format("File Storage system");
strcpy(hdrs.title,s);
s.Format("1.0");
strcpy(hdrs.version,s);
fi.seekp(0,ios::cur);
fi.write(reinterpret_cast <char*> (&hdrs),sizeof(header));
fi.write(reinterpret_cast <char*> (&k),hdrs.index * sizeof(file));
fi.close();
after saving a number of data items the index looses count and gives me a number:-858993460
It works sometimes for a while before loosing count and other times right off the start..
any ideas why?
-- modified at 20:15 Monday 8th January, 2007
|
|
|
|
|
I can't see and "<"s or ">"s in your code. This makes it hard to see what you're casting to.
Steve
|
|
|
|
|
"<"char * ">"
sorry, did not notice it would not show up!
|
|
|
|
|
"<"char * ">"
They are all the same... I am just learning on how to do this..
This file.dat is pre-created
at the start of the program-with just the header and index set to 0..
I use a dialog box and CEdit box to get entries.
-- modified at 20:50 Monday 8th January, 2007
|
|
|
|
|
Try using the ios::binary flag. i.e.
ifstream op("file.dat", ios::binary);
Steve
|
|
|
|
|
I have - I am not sure why its doing this!
last night I saved 150 data items and read them fine.. once it hit 151 it crashed . I deleted that file and started again and I entered 6 items and it crashed?
I am lost on what is causing this- I can't tell if its before the save or during. I have tried debuging it I can only think its happening during the saving process?
since it works some of the time..
by the question I trying yo solve is why..
hdr.index++;//could this be the problem?
|
|
|
|
|
I'm not sure. I'd need to see more code.
Steve
|
|
|
|
|
|
I'm not sure, why you have not used c'tor to initialize member variables.
Dosin wrote: class header
{
public:
char version[6];
char title[20];
int index;
header();
virtual ~header();
};
Not sure , whats happening there. But, change datatype of index to long . And initialize all variables in c'tor.
|
|
|
|
|
Well I think I figured it out-it was the nocreate.. for some reason it stopped the file from writing at random.. I changed it to ios::binary - it seems to be working - more testing it needed.. the size int is fine for my program.. I am making a program to hold up to 15000+.. files.. (why you have not used c'tor ) I just needed a data class and used the class instead of a struct.. It works kind of like a bitmap file.. If you read or create a bit map you can use a strut or a class.. if for some reason it fails again I will try that! thanks for all the help!!!
so far 103 entries and no errors! Ya!
|
|
|
|
|
You classes have virtual functions. For one thing, you shouldn't "twiddle bits" is classes that have (virtual functions) in the manner you are. In classes with virtual functions the compiler inserts code in the constructor and destructor to initialise the vtable pointer: your code will stomp of the compilers good work if the vtable is located at a different address (either because of a rebuild or code in a DLL being relocated). This is a classic example of what can happen when low level constructs such as "bit twiddling" are mixed with high level ones such as virtual functions.
Steve
|
|
|
|
|
I am testing the release version so far so good.. I do have one more question if you don't mind...
In a CListView/Ctrl MFC APP .. what would be the best way to update the data in the view after the dialog box is closed?
Thanks again for all the help!
|
|
|
|
|
I'm not sure with your app. Normally the document would exposed the functions to update the data. By the way, as I mention earlier, it is wrong and dangerous to do what you're doing to calsses that have virtual functions.
Consider this example program:
#include <string.h>
class CWrongBase
{
public:
CWrongBase() {}
virtual ~CWrongBase() {}
};
class CWrong : public CWrongBase
{
public:
int m_Num;
};
void main()
{
CWrongBase *pBase = new CWrong;
memset(pBase, 0, sizeof(CWrong));
delete pBase;
}
Steve
|
|
|
|
|
virtual ~header(); was just left in and will be removed - it is not needed or being used in this app... The class wizzard puts this code in on generation..in c style code they used structures instead of classes.. make a (class test) and a (struct test) in a .h file and save them - they are the same size.. so I create an array of the class for storing data.. It works like a data base or will once its complete..I guess it depends on the app- and if it works with no errors and no bugs since I removed that ios::nocreate- so far its working..
thanks again!
|
|
|
|
|
Hello,
I cant get my checkbox to work. Here is my problem.
I need to do this.
If the checkbox is check when I check it I need to uncheck the checkbox and if it uncheck when I press it I need to bring up a new dialog window. I cant get this to work.
|
|
|
|
|
Are you using MFC?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|