|
#include conio.h
#include iostream.h
void main (void)
{
cout << "Hello World!\n";
getch();
// If I use return 0; there comes an error
}
Thomas
|
|
|
|
|
"return 0;" gives you an error because void functions return no values.
|
|
|
|
|
Your signature for main is strictly wrong - should be
int main(int argc, char* argv[])
Then you return an int - ie 0 or anything else u want
|
|
|
|
|
In the book that I hired from the library and another one that I have at home both say this:
#include iostream.h
void main(void)
{
cout << "hello world";
}
The problem is they used to work but know I can only open them in DOS that's not a problem for me but if I want to mail someone else my work and they don't know how to use DOS then it's a little problem.
Thomas
|
|
|
|
|
jaapdeboer wrote:
The problem is they used to work but know I can only open them in DOS that's not a problem for me but if I want to mail someone else my work and they don't know how to use DOS then it's a little problem.
The executable itself will launch inside a command prompt as you have written it. If you want a windowed application you will need to write it as such.
- Nick Parker My Blog
|
|
|
|
|
jaapdeboer wrote:
In the book that I hired from the library and another one that I have at home both say this:
#include iostream.h
void main(void)
{
cout << "hello world";
}
Not being funny, but those books are either full of crap, or seriously outdated (by at least 5 or 6 years). main returning void is non-standard (it can accept a void type for the parameter list). main does not require a return, however if it is missed, then there is an implicit return 0 included.
Ian Darling
"The different versions of the UN*X brand operating system are numbered in a logical sequence: 5, 6, 7, 2, 2.9, 3, 4.0, III, 4.1, V, 4.2, V.2, and 4.3" - Alan Filipski
|
|
|
|
|
Hi!
I'd like to display a transparent PNG in a CDialog using MFC. How to do that best?
Kind regards...
Michael
|
|
|
|
|
I've used Davide Pizzolato's CxImage[^] library to do this sort of stuff; it works like a charm.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, I've been coding visual c++ for a while now, and made a couple of nice little MFC applications. However I have a kind of general question about the next stage. I can get the applications to work from visual C++ but obviously that's not ideal for distribution, so my question is (sorry if this is stupid)
1. What exactly is the purpose of an installer i.e. install shield etc, as when I build my app in c++ i just get an exe file, no changes in registry or other files?(don't think my question is well worded )
2. Where do i get one/ how do i implement it.
Thanks
Andy
ps another question if i want to read a particular file format into my application say *.jpg for example, how can i do this, surely I don't have to write the code from scratch or do I have to buy a proprietary library?
|
|
|
|
|
1. Your program usually has a number of dependencies, which most commonly are DLLs implicitly used by your program at run-time. An installer makes sure that the target machine already has these DLLs and install the missing ones (an installer can do quite some things more, but this is its main functionality.) Most DLLs are system DLLs and you won't have to worry about them. Make this little test: copy your executable to a fresh machine (OS just installed) and see what happens. The system will guide you about what DLLs are missing. One important case is MFC distribution DLLs: usually, it is preferrable to build your app as statically linked against MFC (see project settings, first tab) so that you don't depend on MFC DLLs at all.
2. Most known commercial installers are InstallShield and Wise (google for them.) Windows has its on installation technology called Windows Installer, but it requires some preloaded services in the target machine which are not natively supported by older OSs. Pablo van der Meer has written a Little Install Builder[^] which may suit your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
i want to read a particular file format into my application say *.jpg for example, how can i do this, surely I don't have to write the code from scratch or do I have to buy a proprietary library?
There are a bunch of different ways to do this.
There are articles here on code project that show how to do this, and there's also FreeImage project (http://freeimage.sourceforge.net/). There are lots of other ones as well, google is your friend
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
hi,
I've have a simple filter graph that takes a mpeg2 file and write its video and audio streams 2 into separate files.
I'm interested in knowing the stream duration prior to playing the graph.
I've used the IMediaDet interface to get the stream length, and also the IMediaSeeking interface (= GetDuration method) and both gave me a time that is longer then the actual stream length time.
i've used a sample grabber in order to count the number of frames and i get allways that the number of frames the methods gave me arn't to the number of frames i've counted using the sample grabber.
Is there another way to know the stream length after i have the graph.
thank in advace
Yogev Cohen
|
|
|
|
|
Hi folks....
How do we switch the focus to another application using its filename in VC++???
heeellllpppp
Pooja
|
|
|
|
|
HWND hwnd = ::FindWindow(NULL,"Program name");
::PostMessage(hwnd,WM_SETFOCUS,0,0);
This should do it.
~Michael
|
|
|
|
|
Hey thanx...
this code works better:
CWnd *pWnd = FindWindow(NULL,”My Application”);
pWnd->SetForegroundWindow();
|
|
|
|
|
Hi all
I wrote a big MFC app wich uses MSXML.
I use it in this way:
MSXML2::IXMLDOMDocumentPtr pDoc(CLSID_DOMDocument)
pDoc->...
...
Few days ago I've installed MSXML 4.0.
Do I have to change my code in order to use the new version? to something like this:
MSXML2::IXMLDOMDocument2Ptr pDoc(CLSID_DOMDocument40)
Or my previouse code will be fine and use the new MSMXL objects?
thanks a lot!
|
|
|
|
|
Anonymous wrote:
Or my previouse code will be fine and use the new MSMXL objects?
Your current code should continue to work (providing Microsoft followed it's own rules on not changing interfaces in COM objects).
COM objects are designed to be backwards compatabile. The only reason you might need to change your CLSID or IID's is if you want to use newer functionality.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
Ok, I understand that, but there are some fixes and performance improvments between the versions. Same Interface will have a better implementation in MSXML 4 then in previous versions, or maybe I'm wrong?
My question is: if I'll leave the code as its now, will it work in the best way and provide the best performance MSXML can provide?
thanks.
|
|
|
|
|
Over time, as I download various bits from the Internet, things tend to get widely distributed on my hard drives. In this particular instance, image files are all over the place, in download folders, in Administrator and User folders - it's a mess. I'd like to create a utility that allows me to enter a file descriptor - a regex might be a good way to do this - and a destination folder, then traverse the entire set of drives and their contained folders to send copies of matching files to the destination folder. Ideally the program would also detect version numbers or last modified dates and only copy the most current versions. What's got me stumped a bit is how to organize the search.
Should I enumerate the top level folders and process them first, then move down a layer and repeat, or should I follow a directory chain to its end before processing the next top level folder? What is a good data structure for keeping track of where I am in the process, and which folders have already been processed? In some ways, the process reminds me of the challenge of traversing rule bases in Prolog, without the cuts, and I never progressed far enough in that language to really get into the implementation details. While I'm at it, will Hidden and System folders be invisible to the process, or does that only apply to displays in Explorer?
Thanks for any suggestions... This might make for a decent Beginner article when it's completed, and I'll be sure to mention any who helped along the way.
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
Roger Wright wrote:
Should I enumerate the top level folders and process them first, then move down a layer and repeat, or should I follow a directory chain to its end before processing the next top level folder?
I don't think it will make any difference, to the outcome, if you do it right.
Regardz
Colin J Davies
* WARNING * This could be addictive The minion's version of "Catch "
It's a real shame that people as stupid as you can work out how to use a computer. said by Christian Graus in the Soapbox
|
|
|
|
|
Directory searches are typically done using a recursive routine and going depth first. Using this approach you don't need to keep track of where you've been. You can get into a mess if you are moving files around etc. under the feet of code that is iterating files. It can be easier and certainly safer to use two passes, one to build the list of files that need to be moved (or whatever) and a second to do the work.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Good thought, and similar to the approach I was discussing with Colin in the wee hours this morning. But then it occurred to me (apparently in my sleep I was still working on it) this morning that the app could get really confused if some process made a change to the file structure after the first pass. That's probably a small risk, though. It might be entertaining and instructive to populate a tree control on the first pass and display it, then expand each node as it is being processed, changing colors or something to indicate completion. It certainly will be a good exercise for my edification!
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
I'm using code like the following to Post some information and instead of using new and delete I'd like to use a smart pointer so I don't need to manually do the delete. I've read over the Boost smart pointer library but can't really see if this is possible. I do use boost scoped_ptr<> to good effect.
CMyClass::MyFunc()
{
CMyClass* pMyClass = new CMyClass;
PostMessage( WM_USER_MYMSG, reinterpret_cast<WPARAM>( pMyClass ), 0 );
}
LRESULT CMainFrame::OnUser_MyMsg( WPARAM wParam, LPARAM lParam )
{
CMyClass* pMyClass= reinterpret_cast<CMyClass*>( wParam );
delete pMyClass;
}
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Well, you can modify the receiving code like this:
LRESULT CMainFrame::OnUser_MyMsg( WPARAM wParam, LPARAM lParam )
{
boost::scoped_ptr<CMyClass> pMyClass(reinterpret_cast<CMyClass*>(wParam));
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|