|
screenshot:
http://www.guiicons.com/high/ICONS.jpg
preview and download xp icons please browse
http://www.guiicons.com
|
|
|
|
|
guiicons wrote:
preview and download xp icons please browse
No spam in the CodeProject forums - please tell someone.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
I have two questions. First is, how can I read and write a text file? I've done this before with fstream, but that method doesn't seem to work at all with MFC.
Second, is there a way I can easily intergrate these text files into the executable? If not, then they could just be kept in the same folder, but it would clean it up a lot if they were apart of it.
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
fstream should work, but it's C. You should use iostreams to read and write text files. Plenty of tutorials on CP.
You should be able to integrate text using resources, depending on how big they are. I've not done it tho.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Can anyone suggest a solid example tutorial for using an MDI app to access a database?
|
|
|
|
|
Hi
I am looking to write a small VC++ utility which inserts possibly a few thousand records at a time into an Access database.
The primary criteria here is efficiency. Which is the more suitable candidate? ODBC or OLE DB?
Any input is appreciated.
thanks
Satheesh
Man Learns from History that he never learns from History
|
|
|
|
|
You wont see much of a performance difference between the OLE DB ODBC provider and using the ODBC API directly. OLE DB is based on COM and it doesnt introduce any overhead. OLE DB is basically to use COM so that we can have a plug-and-play architecture for application components.
|
|
|
|
|
You can choose OLEDB. because ODBC is a generailised interface it will take some more time than OLEDB.
all the best
|
|
|
|
|
What's the easiest way to read in a large file to parse out specific dat from. Sometimes this file can be over a meg. I know I can open it with CFile and read it that way. but then I need to find specific words (using a token). Is there another class that will allow me to read in the file line by line until I hit end of file?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
One solution is file-mapping given that you just want to read the file.
Kuphryn
|
|
|
|
|
yes there is one function in CRT (C runtime library) 'gets' function. it read a next line in the stream. befor using that, you have to set your default intput stream as your file stream. for change your file stream as the default input stream freopen.
The freopen function can be used to redirect the streams to disk files or to other devices.
1. open a file in read mode.
2. redirect the stdin input stream as the standart input stream.
3. use gets function for get a line of string from the file(upto \n char).
4. use while loop to go over the file until eof .
all the best
|
|
|
|
|
I figured it out. I'm using the CStdioFile class and reading in a line at a time. Works great. Thanks all
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Is it possible to use a list to store templated classes in C++? The compiler chokes and gives me a C3203 error in Visual C++.
|
|
|
|
|
Try using typedef.
Kuphryn
|
|
|
|
|
|
Here is the code
namespace mrg
{
template<class _Ty> class mrgFwdPt
{
public:
mrgFwdPt()
{
}
mrgFwdPt(_Ty v, Date dt) : _mVal(v), _mFwdDt(dt)
{
}
~mrgFwdPt()
{
}
inline void SetValue(_Ty v) { _mVal = v; }
inline void SetDate(Date d) { _mFwdDt = d; }
inline _Ty GetValue(void) { return _mVal; }
inline Date GetFwdDt(void) { return _mFwdDt; }
// these operators work on the date objects to allow
// sorting of the forward points by date
bool operator>(const mrgFwdPt<_Ty>& right) const;
bool operator<(const mrgFwdPt<_Ty>& right) const;
bool operator>=(const mrgFwdPt<_Ty>& right) const;
bool operator<=(const mrgFwdPt<_Ty>& right) const;
bool operator==(const mrgFwdPt<_Ty>& right) const;
bool operator!=(const mrgFwdPt<_Ty>& right) const;
protected:
_Ty _mVal;
Date _mFwdDt;
};
template<class _Ty> bool mrgFwdPt<_Ty>::operator>(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt > right._mFwdDt);
}
template<class _Ty> bool mrgFwdPt<_Ty>::operator<(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt < right._mFwdDt);
}
template<class _Ty> bool mrgFwdPt<_Ty>::operator>=(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt >= right._mFwdDt);
}
template<class _Ty> bool mrgFwdPt<_Ty>::operator<=(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt <= right._mFwdDt);
}
template<class _Ty> bool mrgFwdPt<_Ty>::operator==(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt == right._mFwdDt);
}
template<class _Ty> bool mrgFwdPt<_Ty>::operator!=(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt != right._mFwdDt);
}
//=========================== end of point class ==========================================//
template<class _Ty> class mrgFwdCrv
{
public:
mrgFwdCrv()
{
}
~mrgFwdCrv()
{
}
bool push_back(mrgFwdPt<class _Ty> fp)
{
_mList.push_back(fp);
return true;
}
bool test_sort(void);
private:
list<mrgFwdPt<class _Ty>> _mList;
};
template<class _Ty> bool mrgFwdCrv<_Ty>::test_sort(void)
{
Date d;
list <mrgFwdPt<class _Ty>>::iterator i;
for (i = _mList.begin(); i != _mList.end(); i++)
{
d = (*i)->GetFwdDt();
cout << d.DateString() << endl;
}
_mList.sort(less<mrgFwdPt<class _Ty>>());
for (i = _mList.begin(); i != _mList.end(); i++)
{
d = (*i)->GetFwdDt();
cout << d.DateString() << endl;
}
}
}
Class mrgFwdPt is a templated class. It works exactly as expected. When the second class mrgFwdCrv is added, the compiler chokes and I get all kinds of errors. What I would like to do is have the second class (mrgFwdCrv) handle a list of the mrgFwdPt classes. I thought about the typedef approach but wouldn't the compiler just make the substitutions I have here?
Thx
|
|
|
|
|
I did some corrections in your code, and now the below compiles with no errors.
Some operator overloadings are omitted ...
-------------------------------------------------------
#include <list>
namespace mrg
{
typedef int Date; // Assumption for this demo only.
template<class _Ty>
class mrgFwdPt
{
public:
mrgFwdPt()
{ }
mrgFwdPt(_Ty v, Date dt)
: _mVal(v)
{ }
~mrgFwdPt()
{ }
protected:
_Ty _mVal;
};
//=========================== end of point class ==========================================//
template<class _Ty>
class mrgFwdCrv
{
public:
mrgFwdCrv()
{
}
~mrgFwdCrv()
{
}
bool push_back(mrgFwdPt<_Ty> fp) // this line.
{
_mList.push_back(fp);
return true;
}
bool test_sort(void);
private:
std::list<mrgFwdPt<_Ty> > _mList;
};
template<class _Ty>
bool mrgFwdCrv<_Ty>::test_sort(void)
{
Date d;
list <mrgFwdPt<_Ty> >::iterator i;
for (i = _mList.begin(); i != _mList.end(); i++)
{
d = (*i)->GetFwdDt();
cout << d.DateString() << endl;
}
_mList.sort(less<mrgFwdPt<_Ty> >());
for (i = _mList.begin(); i != _mList.end(); i++)
{
d = (*i)->GetFwdDt();
cout << d.DateString() << endl;
}
}
}
void main()
{
mrg::mrgFwdPt<int> aa;
mrg::mrgFwdCrv<long> bb;
}
------------------------------------------------
------ Build started: Project: TestDos, Configuration: Debug Win32 ------
Compiling...
main.cpp
Linking...
Build log was saved at "file://d:\Tmp\TestEnv\VC7\DOS\TestDos\Debug\BuildLog.htm"
TestDos - 0 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 1 succeeded, 0 failed, 0 skipped
<b>Maxwell Chen</b>
|
|
|
|
|
Worked like a champ. Thanks very much.
|
|
|
|
|
I'd need help on converting a char* to a dword OR a byte[4]
thanks!
|
|
|
|
|
i don't know if this is what you are looking for
but my this will help
<br />
DWORD str_num = atoi("12345");<br />
Pain is a weakness living the body
|
|
|
|
|
Didn't work
Actually I have a string like " b7333109 " and I wanna convert it to a dword
|
|
|
|
|
|
I am trying to overload a comparison operator in a templated class and while the class files compile without complaint, the actual comparison statement prompts a C2678 compiler error:
error C2678: binary '>' : no operator found which takes a left-hand operand of type 'mrg::mrgFwdPt<_Ty>' (or there is no acceptable conversion)
with
[
_Ty=double
]
relevant code is
namespace mrg
{
template<class _Ty> class mrgFwdPt
{
public:
mrgFwdPt()
{
}
mrgFwdPt(_Ty v, Date dt) : _mVal(v), _mFwdDt(dt)
{
}
~mrgFwdPt()
{
}
inline void SetValue(_Ty v) { _mValue = v; }
inline void SetDate(Date d) { _mFwdDt = d; }
inline _Ty GetValue(void) { return _mValue; }
inline Date GetFwdDt(void) { return _mFwdDt; }
// these operators work on the date objects to allow
// sorting of the forward points by date
bool operator>(const _Ty& right) const;
private:
_Ty _mVal;
Date _mFwdDt;
};
template<class _Ty> bool mrgFwdPt<_Ty>::operator>(const _Ty& right) const
{
return (_mFwdDt > right._mFwdDt)
}
}
in the main program:
mrgFwdDt<double> one, two;
.
.
.
if (one > two) <- generates the compiler error
FWIW the date comparison operator works correctly and the date class has been used as is for a couple years.
Running MS Visual Studio .Net 2002 (C++ ver 7)
Thx
|
|
|
|
|
Never mind, The parameter passed in the operator declaration and definition were incorrect, should have been classes.
|
|
|
|
|
Hi, I just came up with some quick C++ problems that I thought some people might like to try out. Post your answers as replies. Good luck!
1) Identify any errors in the following declarations.
a. int x[4] = { 8,7,6,4,3 };
b. int x[] = { 8,7,6,4 };
c. const int SIZE = 4;
int x[SIZE];
2) What is wrong with the following piece of code?
int sample_array[10];
for (int index=1; index<=10; index++)
sample_array[index] = 3*index;
3) Suppose we expect the elements of the array a to be ordered so that
a[0] <= a[1] <= a[2] <=…
However, to be safe we want our program to test the array and issue a warning in case it turns out that some elements are out of order. The following code is supposed to output such a warning, but it contains a bug. What is it?
double a[10];
<some code="" to="" fill="" the="" array="" a="" goes="" here.="">
for (int index = 0; index <10; index++)
if(a[index] > a[index +1])
cout <<”Array elements”<
|
|
|
|