|
After a lot of wrong examples from googling the web, I finally find something that works:
myFileName = file;
inp.open(myFileName.c_str(), ifstream::in);
inp.close();
if(inp.fail())
{
inp.clear(ios::failbit);
cout << "No File found " << myFileName.c_str() << endl;
exit(5);
}
else
{
cout << "Found File" << myFileName.c_str() << endl;
}
Thanks, hope this might help someone else...
Bye the way is this board only for Visual C++ or can someone working on Linux with C++ ask Qs?
|
|
|
|
|
meixiang6 wrote: Bye the way is this board only for Visual C++ or can someone working on Linux with C++ ask Qs?
We pretty much assume Visual C++ here, mostly even MFC is assumed to be used. Just in case you hadn't noticed the name of this board, it is MFC/C++.
You can ask C++ on Unix/Linux questions here, but you must let us know of it when posting your question.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
meixiang6 wrote: ...I am running C++ in linux...
It helps to mention this little requirement up front.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
meixiang6 wrote: How do I check the existence of a file in C++?
It's not C++, but you can use _access() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
The standard way of checking file existence on *nix (it works on Windows as well) is stat or fstat[^], I believe.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I will give it a try tommorrow...thanks!
|
|
|
|
|
You can also try in Windows,
if ( 0 == _access( database.c_str(), 0 ) ) {
cout<<"No database found.\n"
} and the nix equivelant is
if ( 0 == access( database.c_str(), 0 ) ) {
cout<<"No database found.\n"
}
|
|
|
|
|
Hi,
I have a requirement where I need to find out whether internet is available or not. How to achieve this using VC++?
THanks
Suhas
|
|
|
|
|
|
Supra2 wrote: How to achieve this using VC++?
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i need a help to read files in the .exe file. help me to solve this problem.
|
|
|
|
|
FindResource
LockResource
etc
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Read files that are in the EXE (as a resource), or read files using an EXE?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi all,
i m write code on OnCtlColor function for color the controls.
HBRUSH CMyPropertyPage2::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
switch (nCtlColor)
{
case CTLCOLOR_EDIT:
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(255,255,255));
return hbr;
case CTLCOLOR_STATIC:
LOGBRUSH logbrush;
m_brush.GetLogBrush( &logbrush );
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(logbrush.lbColor);
return m_brush;
case CTLCOLOR_BTN:
case CTLCOLOR_MSGBOX:
case CTLCOLOR_DLG:
return m_brush;
default:
return m_brush;
}
}
when i use this same code for dialog box its working fine,but in case of property pages its not working fine.
the problem is that its not color the background of RadioBox,CheckBox,GroupBox type controls.
please help me for this.
and tell me solution for this.
thanks in advance
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I don;t know the answer to your probklem, but I know where I'd start looking...
Spy++. Keep an eye where the messages go - maybe to the propertysheet, maybe to the propertypage... But you can find out!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Actully i dont understand that you say i have no idea of SPY please explain me.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Well, in VC6, it's a program under the tools menu, and it exists in later versions of Visual Studio also.
It monitors messages between windows, so you can see for yourself where messages end up.
(It's called Spy++ - sorry if I misnamed it before).
It takes a little practise to use, but it's very powerful.
Good luck,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
i m using VC2005.
thanks.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Hi,
We have planned to convert the project from VC++6.0 to VC+.net .
But i have no idea about this.
Is there any problem will come by converting or any tutorila is available for this?
Pls help me.
Anu
|
|
|
|
|
This[^] blog post on MSDN has links to a number of topics that should help you.
|
|
|
|
|
Is there any articles which help me to connect with a sqlite database using VC2008?
And how will I include dll/lib files to my project?help me.
|
|
|
|
|
CodeProject has a Database articles section (hidden on the "Chapters" pane on the left side...)
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
I am able to display Images in Lisbox one by one in single column.I want to Display Images as rows and columns.Can anyone suggest me how to do it.
Rekha.
modified on Saturday, February 21, 2009 4:43 AM
|
|
|
|
|
A list control (CListCtrl [^] in MFC) is much easier to use for that purpose.
|
|
|
|