|
template <class t="">
class Array
{
protected:
T* data;
unsigned int base;//the base of Array
unsigned int length;//the length of Array
public:
Array();
Array(unsigned int ,unsigned int=0);
Array(Array const&);//copy constructor
~Array();
void SetBase(unsigned int);//i myself can set base of array
void SetLength(unsigned int );
unsigned int GetBase() const;
unsigned int GetLength() const;
T const* Data()const;
};
|
|
|
|
|
|
hi Dominik and all,
I have downloaded the email sample from
http://www.naughter.com/smtp.html
i looks very nice, but i still can not make it work
error is "can not connect to server"
i use phone line home - what i need to fill in configuation dialog box?
thx
includeh10
|
|
|
|
|
The name of your SMTP server.
I'm a bit wary of aiding you, many uses of what you want to do are dubious and you haven't explained why you want this functionality.
Paul
|
|
|
|
|
we have many customers, we need to tell them same news every month, it wastes time.
this app will be a good help.
the process is: read email addresses from list then send news one by one.
name of SMTP server? why does the app always say "can not connect to"?
could u give me a sample string?
i use the string "203.161.1.284" - from gethostname(), is this right?
cheers
includeh10
|
|
|
|
|
I'd expect something like smtp.myisp.com. Your value isn't a valid IP address, FWIW. It'll be the same address that your current email client uses.
In SMTP you only need to make one connection, then you provide the list of addresses, then the message. It's worth reading the relevant RFCs (821/822 are the originals) then you'll have some understanding of the process. Creating a basic SMTP client isn't really very difficult, the complications arise when you start looking at authentication and MIME etc.
Paul
|
|
|
|
|
Paul,
thx for fast reply.
this is not my ip address because i don't know myself - except i copy from ipconfig.
i am testing this program now home, i use phone line to connect to the internet.
my current info is idxwc04-184.idx.com.au, could i change the string to name of SMTP server? or how can i get the name of SMTP server?
cheers
includeh10
|
|
|
|
|
There are two ways to send email from your machine to a@b.com.
1. Do a DNS query for the MX record for b.com. Connect to the SMTP server on that address. Send your email using SMTP.
2. Connect to your local SMTP server, usually supplied as part of your Internet package by your ISP. Send your email using SMTP. This server will relay it to the b.com server.
The former is not guaranteed to work because there is a growing trend to only accept email from a whitelist of IP addresses and your home machine is unlikely to be on the whitelist whereas your ISP's SMTP server is. This is the way that viruses and spammers tend to operate.
So you need to do the latter. You will know what your local SMTP server is because your ISP will have told you and that is how your (for example) Outlook Express connection will be set up.
If you have an Internet connection that doesn't provide Email, and so doesn't provide an SMTP server then I don't see how you can reasonably expect to proceed.
Paul
|
|
|
|
|
Paul,
by ur instructions, i sent an email to my ISP - use outlook - but i don't know if it is in SMTP format.
before i read papers, could u tell me how to send email uing SMTP?
if outlook is not using SMTP, what is it using? is there a c++ sample similar to outlook?
thx
includeh10
|
|
|
|
|
I can't tell you what Outlook is using, I expect it's SMTP.
Paul
|
|
|
|
|
how do you maximize a child window?? its probably on the oninitialupdate()...help
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
Override PreCreateWindow() in your child frame class and make sure cs.style includes WS_MAXIMIZE .
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
That doesn't work.
Any other thoughts???
-B
|
|
|
|
|
stl list & iterators
I've got a list for XML objects. i'm using the std::list
i declare an iteraror, and set it to the beginning of the list
<br />
XML::iterator i = this->begin();<br />
then i want to go to the 'num' positon of the list, so i use this for bucle:
<br />
for(int ii=0; ii<num ;i++, ii++);<br />
that code is ok, i can see what's on the list.
The problem is that i don't know how to delete that position. the following code doesn't seem to work...
<br />
this->erase(i,i);<br />
do you have any ideas? this is my first project with stl.. i've read Eckels Thinking In C++ vol 2 and i can't find anything.. he speaks about a remove method, but i can't use it
thanks!!
|
|
|
|
|
Hi there,
In order to erase only one element, where the iterator is, use this sintax
iterator erase(iterator it);
Let me show you an example
list<int> myList;
list<int>::iterator it;
<br><br>
myList.push_back(1);
myList.push_back(2);
myList.push_back(3);
<br>
for(it = myList.begin(); it!=myList.end(); it++)
ATLTRACE(_T("%i\n"), *it);
<br>
it = myList.begin();
it++;
<br>
myList.erase(it);
<br>
for(it = myList.begin(); it!=myList.end(); it++)
ATLTRACE(_T("%i\n"), *it);
Try it, it should work.
Fabian
|
|
|
|
|
Hi,
Is there any way to change the location of source files for a project? I have all my sources in one directory and the project files in other directories. Now I would like VS to start looking in that source directory whenever I add a new or existing item.
Is that possible?
regards
Ludde
|
|
|
|
|
please help.... anyone? I have searched the docs in vain...
|
|
|
|
|
Hi!
Recently i downloaded an article from this page. This project was programmed in C++ with managed extensions and serves as a .NET Wrapper around a existing C++ implementation of random generators and distributions.
I added this project to my solution that consist of a C# windows application. Under VS.NET 2003 everything worked well and i could use the wrapped random generators and distributions.
Unfortunately, i had to move my solution back to VS.NET 2002. My C# windows application still works well, but the downloaded project doesn't get compiled. I receive the following errors, which i noted besides the lines that generate them:
<br />
template<class T><br />
struct ptr_helper<br />
{<br />
typedef T value_type;<br />
typedef T& reference_type;
typedef const T& rvalue_type;
static reference_type ref(T& r) { return r; }
static const T& ref(const T& r) { return r; }
};<br />
This struct is declared in a header-file of the existing C++ implementation that gets wrapped by the downloaded project.
Why can i compile this under VS.NET 2003 but not in VS.NET2002? What i can i do?
THX in advance
|
|
|
|
|
I believe it was VS.NET 2003 that finally fixed a lot of the bugs in Microsofts C++ compiler. If you're passing a reference to a reference, just change the code to not do that.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Does anyone know how to use ifstream to read binary files over 4 GB in size?
Environment: Microsoft Visual C++ 6.0.
We have a simulator that can generate huge amounts of time-series data. We store this data in binary files. We then read that data as needed for charts, map views, etc. To read a particular item, we use the known layout of the binary files to compute the offset from the beginning of the file:
m_iFstream.open(strFName, ios::in | ios::binary);
int totalOffset = timeStepOffset + ObjectOffset + attributeOffset;
char* buf = NULL;
buf = new char[nLength+1];
m_iFstream.seekg(totalOffset, ios::beg);
m_iFstream.read((char*)buf,(sizeof(char)) * nLength);
buf[nLength] = '\0';
We then copy the read buffer into float.
This works great until the offset exceeds the MAX_INT value. To overcome that, I tried a series of relative offsets as needed, using 64-bit integers to provide a little "head room":
m_iFstream.open(strFName, ios::in | ios::binary);
__int64 llTotalOffset = llTimeStepOffset + objectOffset + attributeOffset;
char* buf = NULL;
buf = new char[nLength+1];
int nRemainingOffset;
if (llTotalOffset < INT_MAX)
{
// Single, direct seek is possible.
//m_iFstream.seekg(0);//seek to begining of file
nRemainingOffset = llTotalOffset;
m_iFstream.seekg(nRemainingOffset,ios::beg);//seek from the beginning of the file
}
else
{
// The offset exceeds what an int can represent.
// Must iteratively seek to the location.
int nMaxSeek = INT_MAX;
m_iFstream.seekg(nMaxSeek, ios::beg); // first seek is from the beginning
llTotalOffset -= nMaxSeek;
while(llTotalOffset >= nMaxSeek)
{
m_iFstream.seekg(nMaxSeek, ios::cur);
llTotalOffset -= nMaxSeek;
}
nRemainingOffset = llTotalOffset;
if (nRemainingOffset > 0)
m_iFstream.seekg(nRemainingOffset, ios::cur);
}
m_iFstream.read((char*)buf,(sizeof(char)) * nLength);
buf[nLength] = '\0';
In theory, this should work. In practice, it doesn’t work consistently. I think the failure must be due to the ifstream class not itself being able to store current file offset (ie same issue we had with variable ‘totalOffset’).
Does anyone know how I might be able to use ifstream in this context?
Note that I did look into declaring a specialized char_traits for the stream. I’m no expert with STL file I/O, but it appears to me that the ‘off_type’ and ‘pos_type’ have to correspond to the ‘char_type’ – so I’m hesitant to try this since we are using the file with standard ‘char’ character type.
Thanks in advance for your advice
Ron Hinthorn
|
|
|
|
|
Hi,
I need to load a large text file into my MFC app and later save changes to disk. What is the best way to do this?
Many thanks
|
|
|
|
|
How about CFile and its Read() and Write() methods?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Will all of the magical and fantastic container classes MFC seems to have brought, I thought there might be a way to read it into some kind of buffer class or something?
Cheers
|
|
|
|
|
ummmmmmm not really
a file has to be read from the disk and put into memory
whether u do it in lil bits or one big a**ed lump
its all the same
"there is no spoon" biz stuff about me
|
|
|
|
|