|
This should do the trick:
ifstream fin;<br />
fin.open("D:\\demo.txt", ios::in); <br />
char szBuffer[255];<br />
<br />
while(!fin.eof()) <br />
{<br />
fin >> szBuffer;<br />
}<br />
The >> operator will extract a string until a valid white space is found.
You have to be carefull about the size of your buffer ! if a word is longer than 255, then you'll have a problem.
See also this:
The extraction operation can be limited to a certain number of characters (thus avoiding the possibility of buffer overflow) if the field width (which can be set with ios_base::width or setw) is set to a value greater than zero. In this case, the extraction ends one character before the count of characters extracted reaches the value of field width, leaving space for the ending null character. After a call to this extraction operation the value of the field width is automatically reset to zero.
|
|
|
|
|
Thanks Cedric Moonen code is working & also for the information.
|
|
|
|
|
Cedric Moonen wrote: You have to be carefull about the size of your buffer ! if a word is longer than 255, then you'll have a problem.
Or just use a string variable instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I checked in the doc of the ifstream (I never use it to read strings so I didn't) and I couldn't find an operator overloading for a std::string. Are you sure it works ?
|
|
|
|
|
I was thinking of something like:
ifstream ifs;
string s;
while (getline(ifs, s))
...
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Oh ok, I thought that you were discussing about using string with the >> operator.
|
|
|
|
|
As an FYI, my solution is to keep the C version. Why change what works?
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hello,
Suppose I am looking at the value of a pointer say
CView* ptr;
In the watch window when I debug, I get the value of ptr as
ptr 0x00326764 View hWnd 0x00000000
so does that mean, that a handle has not got its value as yet for CView pointer since the value of handle is 0 and that in future the handle will not function.
Does NULL value for handle indicate something ?
Correct me if I am wrong.
Prithaa
|
|
|
|
|
prithaa wrote: Does NULL value for handle indicate something ?
It means window is not created for CView object you are talking about.
This handle is generally initialized by call to Create .
|
|
|
|
|
|
Dear All,
I am working with MFC Extension dll. I have two dialogboxes ( Main and Sub Dialog). The Main Dialog is present in an exe. This Main dialog calls sub dialog that resides in a MFC Extension dll. This sub dialog has few controls like buttons and listcontrol, its corresponding eventshandlers and classes.
At Execution, When i click on any control of sub dailog , eventhandlers are not coming up.
Why ? What could be the problem ?
Thanks.
|
|
|
|
|
sakthimuthu wrote: At Execution, When i click on any control of sub dailog , eventhandlers are not coming up.
I havn't done that .. but you can try Subclass WndProc in the SubDialog and try to see message routing
|
|
|
|
|
The two must use the same scheme for linking MFC. If the EXE statically links to MFC and the extension DLL dynamically links to MFC, that could be your problem.
Make sure the subdialog, from the extension DLL, has the main dialog as its parent and was not created with 'no parent'.
|
|
|
|
|
I am a beginner in using a list control. Could someone direct me in how to set the color of the cells (I hope this is the correct terminology) containing the column names in the list control, as well, setting the color of the first cell in each row. The color will be blue.
Thanks
Trevy
|
|
|
|
|
See here[^].
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I think you need to use custom draw . Refer this article by Michael Dunn[^].
|
|
|
|
|
|
Hi all,
Actually, i have made a SDI application. In my sdi application i have made a splitter control which is dividing my frame in 2 parts(vertically).Now what i want to do is, when i click on a button in my toolbar i want that splitter control to be removed n a simple sdi window to come as it comes when we initially create as sdi frame....
How to do it?
Thanxs in advance
|
|
|
|
|
better make new application.. that must much easier
|
|
|
|
|
It's actually rather simple. I've done exaclty what you're looking for by creating my own CSplitterWnd derived class. You can do something like this:
void CMySplitterWnd::ShowViews(bool bShowView1, bool bShowView2)
{
ASSERT(bShowView1 || bShowView2);
int nViewCount = 0;
if (bShowView1)
nViewCount++;
if (bShowView2)
nViewCount++;
m_nCols = m_nMaxCols = nViewCount;
CRect rc;
m_pView1->GetWindowRect(&rc);
m_sizeView1 = rc.Size();
m_pView2->GetWindowRect(&rc);
m_sizeView2 = rc.Size();
int nMyViewCount = 2;
m_pView1->SetDlgCtrlID(AFX_IDW_PANE_FIRST + nMyViewCount++);
m_pView2->SetDlgCtrlID(AFX_IDW_PANE_FIRST + nMyViewCount++);
int nCount = 0;
if (bShowView1)
{
m_pView1->SetDlgCtrlID(AFX_IDW_PANE_FIRST + nCount);
m_pView1->ShowWindow(SW_SHOW);
SetColumnInfo(nCount, m_sizeView1.cx, 0);
nCount++;
}
else
m_pView1->ShowWindow(SW_HIDE);
if (bShowView2)
{
m_pView2->SetDlgCtrlID(AFX_IDW_PANE_FIRST + nCount);
m_pView2->ShowWindow(SW_SHOW);
SetColumnInfo(nCount, m_sizeView2.cx, 0);
nCount++;
}
else
m_pView2->ShowWindow(SW_HIDE);
RecalcLayout();
}
Edit: Forgot some important code
|
|
|
|
|
I have just designed a look alike RADAR display for which, i have used a static text box as the canvass I have drawn a circle with a line going round at the rate of 1.5 seconds per rev.
Now i have to plot points on this circle.
I have 2 problems
1> My display flickers with every rev of the needle
2> I have used Mapping mode- MM_ISOTROPIC but i am unable to understand how to convert points to the disagram(circle which is the radar display
|
|
|
|
|
anu7873 wrote: I have just designed a look alike RADAR display for which, i have used a static text box as the canvass I have drawn a circle with a line going round at the rate of 1.5 seconds per rev.
Now i have to plot points on this circle.
for First handle WM_ERASEBKGND PRE.clsCode { font-size:110%; } PRE.clsSyntax { font-size:100%; } TD DIV.clsBeta { display:none;} A:link { color:#0000ff; text-decoration:underline;} A:visited { color:#0000ff; text-decoration:underline;} A:hover { color:#3366ff; text-decoration:underline;} MSHelp\:link { color:#0000ff; text-decoration:underline; cursor:hand; hoverColor:#3366ff; filterString: ;} // // // // // //<ph:chm><ph:data><xml id="_topicdata" pagetype="winnotify" proj="WinUIHXS" name="WM_ERASEBKGND" pubpath="/WinUI/WindowsUserInterface/Resources/Icons/IconReference/IconMessages/WM_ERASEBKGND.htm"><root><xml xmlns:mshelp="http://msdn.microsoft.com/mshelp"><mshelp:keyword index="A" term="_win32_WM_ERASEBKGND"><mshelp:keyword index="A" term="_win32_WM_ERASEBKGND_cpp"><mshelp:toctitle title="WM_ERASEBKGND Notification"><mshelp:rltitle title="WM_ERASEBKGND Notification ()"><mshelp:keyword index="F" term="WM_ERASEBKGND"><mshelp:keyword index="K" term="WM_ERASEBKGND"><mshelp:attr name="TopicType" value="kbRef"><mshelp:attr name="Locale" value="kbEnglish"><mshelp:attr name="DevLang" value="C++"><mshelp:attr name="Technology" value="WinUI"><mshelp:attr name="TechnologyVers" value="kbWinUI"><mshelp:attr name="DocSet" value="WCSDK"><mshelp:attr name="DocSet" value="LHSDK"><mshelp:attr name="DocSet" value="PSDK"><mshelp:attr name="TargetOS" value="Windows"><mshelp:attr name="TopicType" value="apiref"><mshelp:attr name="APIName" value="WM_ERASEBKGND"><mshelp:attr name="APIType" value="NA"><mshelp:attr name="TopicType" value="winnotify"> notifcation
|
|
|
|
|
Something messed up with your post.
|
|
|
|
|
prasad_som wrote: Something messed up with your post.
i am just copying from MSDN.. thanks for same!, reposted
|
|
|
|
|
I think you use of a encoding system for your answer ;)
|
|
|
|