|
ifstream ifs;
ifs.open( "sample.txt", ifstream::in);
if( !ifs.is_open()) {
}
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
hi
still the same problem exists.The code is not checking whether the file is opened or not, its getting some values from some other location.
swaroop
|
|
|
|
|
swaroopkb wrote: still the same problem exists
And what is the problem? You are vague.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
sorry for the troubles,
could u please tell me how to close or destroy an ifstream object, i think thats the problem when the program run ifstream object is having the buff value, its not getting cleared. Even if the sample.txt file is not there the buff is showing the contents of sample.txt, could u please tell me y is it so ???
swaroop
|
|
|
|
|
std::ifstream has a close() -function, which flushes all buffers and closes the file.
It destructor is also calling close, so you could simply let the stream-object go out of scope.
Hint: You can introduce a scope by simply opening a { writing your code and closing the scope with }
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
swaroopkb wrote: the buff value, its not getting cleared
To clear the buffer of istream , use std::basic_istream::ignore .
std::fstream f("a.txt", std::ios::in);
std::cout << f.rdbuf();
std::cout << "\n---\n";
std::streamsize n;
f.seekg(0, std::ios::end);
n = f.tellg();
f.seekg(0, std::ios::beg);
f.ignore(n);
std::cout << f.rdbuf();
Maxwell Chen
|
|
|
|
|
Does this work?
void main( void )
{
std::ifstream ifs;
ifs.open("<path_of_file>\\sample.txt");
if (! ifs.is_open())
std::cout << "File not opened\n";
else
std::cout << "File opened\n";
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
Is there any way to call non static method in static method of a class, actually i have a static method of my class and i want to call MessageBox function but i get this error "'CWnd::MessageBoxA' : illegal call of non-static member function", is there any way to call that.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language; please excuse any grammatical or spelling mistakes"
|
|
|
|
|
Try using AfxMessageBox .
Regards,
Paresh.
|
|
|
|
|
Mushq wrote: Is there any way to call non static method in static method of a class
the general answer is: no, you need an instance of the object to call non-static members.
|
|
|
|
|
My form is derived from CDialog, and I have add a menu in it. Now I want to want the menu's background color. Does anybody know how?
Thanks in advance!
Best Regards,
Peter
|
|
|
|
|
Lots of people do. Have a look in code project for owner draw menu articles. Many of them have lots of nice features as well.
It's sadly not a case of handling a WM_MENUCOLORPLS message, and does involve quite a bit of hacking about, so there's no short answer.
Iain.
|
|
|
|
|
|
Thanks!
|
|
|
|
|
|
How can i detect the existing browsers in a system or
how to check whether mozzila ,netscape or opera installed or not in PC
|
|
|
|
|
One way would be to see what application is associated with .htm and .html files.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi
I wrote the code for minimising the application that are active while I launch my application.
But one error is coming "cannot convert from 'HWND' to 'CWnd *'"
CString szTitle;
CWnd *pTopWnd;
UINT cmd=GW_HWNDFIRST;
while (pTopWnd=GetWindow(NULL,cmd))
{
pTopWnd->GetWindowText(szTitle);
if(szTitle.Find("MyApp.EXE")>=0)
pTopWnd->ShowWindow(SW_HIDE);
cmd=GW_HWNDNEXT;
}
Plz tell the solution
|
|
|
|
|
Your GetWindow() is returning an HWND and you are trying to assign that directly to a CWnd*. Do the following instead:
HWND hWnd = GetWindow(NULL,cmd);
CWnd *pTopWnd = CWnd::FromHandle(hWnd);
"What's on your mind, if you will allow the overstatement?"
|
|
|
|
|
I modified the code as :
CString szTitle;
HWND hWnd = GetWindow(NULL,GW_HWNDFIRST);
CWnd *pTopWnd = CWnd::FromHandle(hWnd);
while (pTopWnd!=NULL)
{
pTopWnd->GetWindowText(szTitle);
if(szTitle.Find(_T("MyApp.EXE"))>=0)
pTopWnd->ShowWindow(SW_HIDE);
hWnd = GetWindow(NULL,GW_HWNDNEXT);
pTopWnd = CWnd::FromHandle(hWnd);
}
But pTopWnd is coming NULL.Why?
|
|
|
|
|
You are passing NULL as the first parameter to GetWindow, you have to provide a valid window handle to GetWindow then only it gets the next window or any window thats related to the window that you provide.
Use GetForegroundWindow function to get the handle to the current active window, then you can use GetWindow to get the next windows. Remember you always have to pass a valid HWND to GetWindow.
"What's on your mind, if you will allow the overstatement?"
|
|
|
|
|
pther wrote: But pTopWnd is coming NULL.Why?
Did you bother to check the return value of GetWindow() , or are you assuming it succeeded and calling FromHandle() anyway?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi!
what does the non-maskable interrupt do?
does it disable other interrupts? whitch interrupts?
Zo.Naderi-Iran
|
|
|
|
|
|
Wish I still gave a <blank> about that level.
Doe’s it still disable other interrupts – no!
Look this is Windows and like most other modern Operating Systems you will need to dig deeper.
Sorry – I am tiered and could be wrong – keep looking -
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|