| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Jan 2005 Location: New Zealand
Posts: 3,746
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | C++ help needed I'm trying to learn C++ and when I compile PHP Code: EDIT: figured it out add this to the header HTML Code: #include <stdlib.h> ????: NamePros.com http://www.namepros.com/programming/470017-c-help-needed.html PHP Code:
__________________ WowHumor.net - Funny World of Warcraft Pictures
Last edited by majinbuu1023; 05-16-2008 at 09:56 PM.
|
| |
| | THREAD STARTER #3 (permalink) |
| Senior Member Join Date: Jan 2005 Location: New Zealand
Posts: 3,746
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Awesome , this is really annoying me, I keep googling it but it isn't showing any results
__________________ WowHumor.net - Funny World of Warcraft Pictures |
| |
| | #4 (permalink) |
| NamePros Regular Join Date: May 2008 Location: England
Posts: 771
![]() ![]() ![]() ![]() ![]() ![]() | Its because the compiler will run the main() method, printing all those lines and then close itself. As a program which leads to the end of the main() method assumes its finished with. You need to pause it as you did, or ask it to wait for input using the std::cin function. Alernatively export an exe and run it in command prompt
__________________ pixelhero Web Development Studios UK |
| |
| | #5 (permalink) |
| DNOA Member Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | For the record, you're coding C. In C++, your program would resemble: Code: #include <iostream>
using namespace std;
int main()
{
cout << "Lol its line one!" << endl;
cout << "Line 2" << endl;
cout << "LINE THREE WTFHAX" << endl;
system("pause");
return 0;
}
Last edited by mholt; 05-20-2008 at 06:43 PM.
|
| |
| | #7 (permalink) |
| NamePros Regular Join Date: Jul 2004 Location: Seattle, Wa
Posts: 596
![]() ![]() ![]() | Well, I know in VB and C# you need to have a readline at the end of the program to make it idle and wait for the user to close the window. Just throw a readline command at the end of the program. It should work. This might not be necessary in C though... |
| |
| | #8 (permalink) | ||||||||||||
| NamePros Member Join Date: Apr 2008
Posts: 82
![]() |
return 0 ends the program. By the way, that is pure C code - you don't use any C++ functions or libraries there In C++ it would be like this:
| ||||||||||||
| |
| | #9 (permalink) | ||||||||
| DNOA Member Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]()
????: NamePros.com http://www.namepros.com/showthread.php?t=470017 Header files with .h extension generally are not in and of themselves C++, as they are plain ol' C libraries. Oh well. Doesn't matter. | ||||||||
| |
| | #10 (permalink) |
| Senior Member Join Date: Apr 2005 Location: Joliet, Illinois
Posts: 1,177
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Are you trying to create a command prompt or WinAPI? I can help if you let me know. I wouldn't recommend using 'printf' for command prompt in C++ programming with 'cout >>' - a lot better for your purposes.-RageD |
| |
| | #11 (permalink) | ||||
| NamePros Member Join Date: Apr 2008
Posts: 82
![]() |
If I did then I apologize. | ||||
| |