| View previous topic :: View next topic |
| Author |
Message |
iHack I post too much
Reputation: 0
Joined: 19 Apr 2006 Posts: 2105 Location: USA
|
Posted: Sat Jan 12, 2008 11:05 am Post subject: Microsoft Visual C++ 2005 |
|
|
Alright I just need some simple help...im confused right now. I download Microsoft Visual C++ off their site...when I installed it , it made a folder entitled "Microsoft Visual C 2005" in my documents, it also installed a folder entitled "Microsoft visual C++ 8.0" in my program files...heres whats happening.
When I open microsoft visual C++ 2005 and try to make an application it saves it into the folder in my documents and nothing compiles properly...to make it compile properly I have to use the visual C++ cmd line that comes with it and compile using:
notepad appname.cpp
cl /clr appname.cpp
after that it compiles the .exe and saves the .cpp into the Microsoft Visual C++ 8.0 folder and works fine, but most of the time depending on what I do I get compile errors and it cant find header files.
It could just be me because iostream.h wasnt found and later found out that it was taken out a while back so I fixed it with
#include <iostream>
using namespace std;
and it compiled, however this brings me to my next question, the .exe opended my Hello World app in the command prompt, is there anyway I can make it display in its seperate form - that says "Hello World" instead of having it display in the cmd - because the cmd doesnt even display but like half a second and shuts down
heres my code:
| Code: | // my dam C++ app
#include <iostream>
using namespace std;
int main ()
{
<< cout "Hello World!"; //considering adding endl function if I can fig it out
return 0;
} |
any help thanks!
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Jan 12, 2008 6:56 pm Post subject: |
|
|
My Documents\Visual Studio 2005\Projects\ is the directory where ur projects save by default and you can compile and build the project by hitting F5
| Code: | #include <iostream>
int main()
{
std::cout << "Hello World\n";
std::cin.get();
return 0;
}
|
including the entire namespace is pointless and u can just use "\n" which is New Line instead of End Line (std::endl)
cin.get() will make you press a button before the app continues to return 0; which closes the app
_________________
|
|
| Back to top |
|
 |
iHack I post too much
Reputation: 0
Joined: 19 Apr 2006 Posts: 2105 Location: USA
|
Posted: Sat Jan 12, 2008 10:34 pm Post subject: |
|
|
i got it all fixed now =D...I found out that I needed to download the 2.0 SDK pack...and it gave me all the include files and I fixed my code to make it fully functional I needed to add the "cin" code so it was:
| Code: | #include <iostream>
using namespace std;
int i; //declared cin with i
int main ()
{
cout << "Hello Everyone!"; // Prints Hello Everyone!
cout << "Im Jay's First Program!"; // Prints Jay's First Program!
return 0;
cin>> i; // waits for a proceed in the cmd
} |
so I basically completed my first simple C++ app and fixed the errors myself with a little research , now im working on sending keystrokes to notepad =D
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Jan 12, 2008 11:05 pm Post subject: |
|
|
not to bring you down or anything but "int i" doesnt declare cin, it declares "i" as an Integer
and ur program wont reach "cin >> i" because the program exits before it gets to it (return 0; )
| Code: | #include <iostream>
int main()
{
std::cout << "Hello Everyone!\n"; // added "\n" to make sure that a new line is placed before it says ur next string.
std::cout << "Im Jay's First Program!" << std::endl; // end the line and await cin.get();
std::cin.get(); // wait for user to hit enter before going ahead to exit
return 0;
} |
that is how your code should look like.
_________________
|
|
| Back to top |
|
 |
iHack I post too much
Reputation: 0
Joined: 19 Apr 2006 Posts: 2105 Location: USA
|
Posted: Sat Jan 12, 2008 11:17 pm Post subject: |
|
|
sorrry im still confused on the terms for C++
all it does (tested alrdy) ..opens up the CMD displays Hello World! Im Jays First Program! and sits there =D
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Jan 13, 2008 8:28 am Post subject: |
|
|
Since no one here said it... you downloaded the Express edition of Visual Studio. Make sure you download the Platform SDK as the download page instructs you to or else you will run into issues while compiling.
_________________
- Retired. |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sun Jan 13, 2008 10:30 am Post subject: |
|
|
lol he said that above:
| iHack wrote: | | i got it all fixed now =D...I found out that I needed to download the 2.0 SDK pack...and it gave me all the include files and I fixed my code to make it fully functional |
yea thats because thats the simpliest applications you can make. before going into anything deeper i reccomend your learn the syntax and headers such has fstream, iostream, string, vector, etc.
so ill explain your simple code in detail
#include <iostream> - Includes the header "iostream" (input/output stream) to your project. (by surrounding the header with "< >" it means that you're linking your project with the header, if you're including a header that is in your solution then you surround the header with quotation marks (" ")
int Main() - Where your program starts
std::cout - in the Std namespace, cout, which is the most basic output system you can use in c++. prints variables to your Cmd prompt
cout << "hello world!\n"; or can be used like this
cout << "hello" << "world\n";
std::cin - in the std namespace, cin, which is the most basic input system you can use in c++. cin will allow you to assign declared variables a value. "cin >> i" would declare "i" with whatver the user inputted.
std::cin.get() - in the namespace std, cin.get(), is another function of cin which stops everything until the user inputs something. this doesnt assign any variables a value.
return 0; - also known as return EXIT_SUCCESS; this will exit your program. any function that is int based must be returned. (int main() must be returned, while void main() doesn't)
anyways hope that quick description helped you
_________________
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sun Jan 13, 2008 10:56 am Post subject: |
|
|
| lurc wrote: | | std::cin.get() - in the namespace std, cin.get(), is another function of cin which stops everything until the user inputs something. this doesnt assign any variables a value. | But it does load the input to the buffer. So, instead of it, if you wanna pause, I'd recommend this one | Code: | std::cin.ignore();
std::cin.sync(); |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sun Jan 13, 2008 11:06 am Post subject: |
|
|
| Jani wrote: | | lurc wrote: | | std::cin.get() - in the namespace std, cin.get(), is another function of cin which stops everything until the user inputs something. this doesnt assign any variables a value. | But it does load the input to the buffer. So, instead of it, if you wanna pause, I'd recommend this one | Code: | std::cin.ignore();
std::cin.sync(); |
|
yea thats a good choice, thanx for that
_________________
|
|
| Back to top |
|
 |
|