|
A "PLEASE" would have been highly appreciated.
istream::getline (member functions)
Declarations:
Form 1 istream& getline(signed char*, int, char = '\n');
Form 2 istream& getline(unsigned char*, int, char = '\n');
istream::getline, Form 1 (member function) Declaration:
istream& getline(signed char*, int, char = '\n');
Remarks:
This form of getline does the following:
_ extracts up to the delimiter,
_ puts the characters in the buffer
_ removes the delimiter from the input stream
_ does not put the delimiter into the buffer
istream::getline, Form 2 (member function)
Declaration:
istream& getline(unsigned char*, int, char = '\n');
Remarks:
Extracts characters into the given char * until one of the following occurs:
_ the delimiter (third parameter) is encountered
_ end-of-file is encountered
_ (len - 1) bytes have been read
>>A terminating null is always placed in the output string.
>>The delimiter is also extracted.
>>The delimiter is not placed into the destination string.
>>Fails only if no characters were extracted.
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
What exactly do you want?? Any specific things..
|
|
|
|
|
Hi !
If I have a list (from the STL) and want to reach the nth element, I'd like to use an iterator, set it to the beginning of the list and do something like It=It+index_to_reach.
It works for the vector, but not for the list. Could anyone tell me how I'm supposed to do ?
Here is how I do it now (with a loop incrementing the iterator) :
#include <iostream>
#include <list>
int main(int argc, char* argv[])
{
int ElementIndexToReach=2;
std::list<int> MyList;
MyList.push_back(1);
MyList.push_back(2);
MyList.push_back(3);
MyList.push_back(4);
std::list<int>::const_iterator It;
It=MyList.begin();
for (int i=0; i<ElementIndexToReach; ++i, ++It);
std::cout << "Expected value : 3. Value : " << (*It) << "\n";
return 1;
}
|
|
|
|
|
You probably want the advance() algorithm. There's a worked example in the VC online help...
// Advance.cpp
// compile with: /EHsc
#pragma warning (disable:4786)
#include <iostream>
#include <string>
#include <list>
using namespace std ;
typedef list<string> STRLIST;
int main() {
STRLIST List;
STRLIST::iterator iList;
STRLIST::difference_type dTheDiff;
List.push_back("A1");
List.push_back("B2");
List.push_back("C3");
List.push_back("D4");
List.push_back("E5");
List.push_back("F6");
List.push_back("G7");
// Print out the list
iList=List.begin();
cout << "The list is: ";
for (int i = 0; i < 7 ; i++, iList++)
cout << *iList << " ";
// Initialize to the first element"
iList=List.begin();
cout << "\n\nAdvance to the 3rd element." << endl;
advance(iList,2);
cout << "The element is " << *iList << endl;
dTheDiff = distance( List.begin(), iList);
}
Output
The list is: A1 B2 C3 D4 E5 F6 G7
Advance to the 3rd element.
The element is C3
Requirements
Header: <iterator>
Kevin
|
|
|
|
|
Like this
#include <iostream>
#include <list>#include <utility>
int main(int argc, char* argv[])
{
int ElementIndexToReach=2;
std::list<int> MyList;
MyList.push_back(1);
// First element
MyList.push_back(2);
MyList.push_back(3);
// Third element
MyList.push_back(4);
std::list<int>::iterator It;
It=MyList.begin(); // First element
std::advance(It, ElementIndexToReach);
std::cout << "Expected value : 3. Value : " << (*It) << "\n"; return 1;
}
This is needed because only random access iterators provide + and - operators. There is also a distance function which is used with non-random access iterators.
Internally, advance does just what you were doing with your for loop.
|
|
|
|
|
How to re-open a existing dialog box in an application ?
Thank's for advance,
|
|
|
|
|
Call DoModal() again.
CMyDialog myDialog (this);
int nStatus = myDialog.DoModal();
if (nStatus == IDOK)
doSomething();
doSomethingElse();
nStatus = myDialog.DoModal();
if (nStatus == IDOK)
doSomething();
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am using ADO recordsets in my C++ program. I am adding a new record by calling AddNew method of recordset object. Now, I dont' want to override any default values set for a particular column while adding the records. How can find whether default values are set for a column, and if set, how can I get the default values. what are the methods available for that?
Thanks in advance
Shenthil
|
|
|
|
|
cross posting
He who controls others may be powerful, But he who has mastered himself is mightier still.
|
|
|
|
|
Is there a limit to the number of threads that you can create? I get this error saying I don't have enough memory to create a thread. I know I have enough RAM but don't understand why I get the error. Can I set it like Windows CE? I'm just using the standard thread create. Thanks.
|
|
|
|
|
Wots the stack size you specifying
greatest thing is to do wot others think you cant suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Wots?? I'm not familar with the term.
|
|
|
|
|
IMHO, it is probably a stack problem.
However, I would bet that you have a poor design. Why do you need to create so many threads? What are you doing in each thread that is blocking?
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Stack problem? I thought the OS took care of it unless you specify in thread create func. Thanks.
|
|
|
|
|
Actually I don't have that many threads. Which confuses me.
|
|
|
|
|
Hi,
Can we hide the menu options, if yes please tell me how?
I don't want to disable them, just want to hide under some circumstances and show up later.
Thanks.
|
|
|
|
|
Hi!
I've been trying to figure this bug out for a week, w/out any progress, so I'd like to ask for you help, maybe there's a well-known workaround.
I have an UDP listen socket, which is to accept incoming data from the INET. The problem arises when I try to do this behind ZoneAlarm( so far I've tried this fwall ). I allow every actions (act as a server even for Inet), but when I switch it on, my socket does not receive a single byte of data, although it works properly w/out firewall.
I've also given it a try with the original MFC CAsyncSocket UDP sample, and viola, it worked, even behind firewall. So I started to compare the two codes, but it turned out that they were exactly the same (the networking part of course). I've also checked the ZA settings and they are exactly the same too.
I create the socket w/ almost the default values:
just
<br />
CAsyncSocketDerivedClass sock;<br />
sock.Create( 0, SOCK_DGRAM );<br />
with this code it gets data without ZA but don't get a single byte behind ZA.
Please, heeelp! Thanks in advance!
|
|
|
|
|
Hello *,
I am a very beginner of graphics applications. No experience at all.
I started to develop such as application in VC++ 6 and I have, let's say, a design problem.
The user should draw a lot of different shapes who fit a grid with 4 different scales. The user can perform a series of operation onto these shapes like: moving, attach it to other shape, removing it and so on.
My problem is: what is more efficient, optimized, profi , ... to use: bitmaps or shapes (this is, if I need a rectangle, I use a bitmap which represents a rectangle or I use CDC::Rectangle(...)).
Thx in advance!
Adrian
|
|
|
|
|
Hello all,
I am trying to implement a HTTP client using MFC. I don't want to open the response the page in browser. The program will send a request to the server specifying the URL. When the server responds, that page should get downloaded. I want to save that page as .htm file in a pre-decided folder.
I have seen some books which tell how to open and display the response page in the browser. But I don't want that. I simply want to download the file and save it.
Being a new programmer, I don't know how to do it. If someone could throw some light on this, it will be really very helpful.
Thanks and regards
Madhavi
|
|
|
|
|
|
use
CInternetSession::GetHttpConnection()
and CHttpConnection object
greatest thing is to do wot others think you cant suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
A week or so ago, I posted a request for help with scrolling large documents - I was hitting the 16 bit limit imposed within SetScrollSizes() and could not scroll to the end of the document. As a reply, I was pointed to look at SCROLLINFO. I have used this in addition to SetScrollSizes() and this initially seemed to solve my problem. It was a short time later that I noticed "a hole" in the window view after scrolling a good way down. I have been disecting my code ad-nauseum without understanding what the problem was. Eventually, I was driven to create a minimal test app to see if the problem was reproduced. It purely prints the line number from 1 to 2155 on consecutive lines. Everything is fine as you scroll down, but when you get to line 2048 (the 32768 pel boundary) a block of blank lines start appearing. Continuing to scroll down, line numbers appear again at either 2056 if scrolling by page, or 2093 if scrolling by line. Scrolling up produces different boundaries, but normal operation does occur at line 2048. (Some of the lines missing in the scroll down "appear" when scrolling up, by the way !!
My OnSize() function for the test app is as below:-
void CTestView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
TEXTMETRIC tm;
CDC *pDC = this->GetDC();
pDC->GetTextMetrics( &tm);
m_sizeChar.cy = tm.tmHeight;
m_sizeChar.cx = tm.tmAveCharWidth;
m_sizeClient.cx = cx;
m_sizeClient.cy = cy;
m_sizeDoc.cx = 1024;
m_sizeDoc.cy = 2155 * m_sizeChar.cy;
CSize sizeLine(1,1);
SetScrollSizes(MM_TEXT, m_sizeDoc, m_sizeClient,sizeLine);
// Following code gets over 16 bit restrictions encountered in SetScrollSizes()
SCROLLINFO info;
BOOL rc;
rc = GetScrollInfo(SB_VERT, &info, SIF_PAGE|SIF_RANGE);
if(!rc)
AfxMessageBox("GetScrollInfo() failed");
info.fMask = SIF_PAGE|SIF_RANGE;
info.nMin = 0;
info.nPage = m_sizeClient.cy;
info.nMax = m_sizeDoc.cy - 1;
rc = SetScrollInfo(SB_VERT, &info, TRUE);
if(!rc)
AfxMessageBox("SetScrollInfo() failed");
}
It's obvious that I'm hitting ANOTHER 16-bit "problem", but I can't see where it is.
Can some kind soul point me in the right direction ! ? Many thanks in advance !
Doug
|
|
|
|
|
Maybe this article will be of help
http://www.codeguru.com/Cpp/W-D/doc_view/scrolling/article.php/c3299/[^]
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
Can anyone pls tell me how to implement a timeout function in C++??
thx very much
|
|
|
|
|
What do you mean with timeout ? What kinod of application : Win32, MFC, or simple C++ project with standard libs ?
~RaGE();
|
|
|
|