Ok, this is in my computer programming class and I'm not really understanding much. My professor gave us a problem which is: What is the output of the following code fragment? string msg = "knowledge"; cout << "This is" << endl << "a test of your" << msg << endl << "." << endl; What exactly does he mean and can you explain. He's not good at explaining he has a lisp and he talks way to fast. Please help :tears: i'm desperate.
cout is the standard output stream - this is sending stuff to the screen to be displayed. When you see the << operator on a stream, it means that something is being sent to that stream. The << operator can be chained together if you are sending multiple things to the same stream. For example Code: cout << "a" << "b" << "c" << "d"; will have the same effect as Code: cout << "abcd"; Both will display as abcd on the screen. So you've got stuff being sent to the cout stream, which will be displayed on the screen. endl is the same as a new line character for output streams - it just makes it start displaying on a new line after that point. (It also does some other things but that isn't important for this situation.) Remember that msg is a variable, so it will output what is stored in that variable.
I think the best way to learn is by doing. So do you have a compiler available to you? Try this (example for GCC): main.cpp Code: #include <iostream> #include <string> using namespace std; int main(int argc, char** argv) { string msg = "knowledge"; cout << "This is" << endl << "a test of your" << msg << endl << "." << endl; return 0; } Code: g++ main.cpp -o main And then run your program and see what the result is.
I did something wrong, a second ago it was working fine. This is what i'm getting 1>LINK : fatal error LNK1561: entry point must be defined ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What compiler are you using? Is the Microsoft compiler on Visual Studio? You need a function called main. The linker doesn't understand where your program starts.
Yes visual studio, and I think main is there. The thing is my professor added a template for us to use and he put it in there already. For some reason it's acting really strange.
In your project settings, is it a console application or a Win32 application? If it's a Win32 application, then your application needs to have WinMain() and be written differently. I think it's easier if you make it a console application and use main() instead. Sorry, I am not really familiar with Windows development tools. http://social.msdn.microsoft.com/Fo...-entry-point-must-be-defined?forum=vclanguage Note to moderators: no, I don't post on MSDN, so this isn't a violation of the Code of Conduct. Ask Owen. Ze would know how I feel about all things Microsoft.