-
March 10th, 2009, 11:37 AM
#1
[RESOLVED] New
Im really new to this! but I'm typing this correctly down but I keep getting an error from it! Help me please..
#include <iostream>
int main()
{
int x= 5;
int y= 7;
std::cout << endl;
std::cout << x + y << " " << x * y;
std::cout << end;
char response;
std::cin >> response;
return 0;
}
Last edited by Vaildinfection; March 10th, 2009 at 11:49 AM.
-
March 10th, 2009, 11:47 AM
#2
Re: New
What's end? Did you intend to write std::endl?
-
March 10th, 2009, 11:49 AM
#3
Re: New
sorry Just fixed it! but I still error an with
std::cout << endl;
Last edited by Vaildinfection; March 10th, 2009 at 11:53 AM.
-
March 10th, 2009, 11:55 AM
#4
Re: New
Either refer to it as std::endl, or else put
Code:
using namespace std;
at the top of your file under the include.
-
March 10th, 2009, 11:56 AM
#5
Re: New
endl declared inside std namespace. So, you should write
Code:
using namespace std;
int main()
{
...
}
or point the namespace explicitly, as you do for cin and cout:
-
March 10th, 2009, 11:58 AM
#6
Re: New
Discovered the above message after posting my one and page refresh.
-
March 10th, 2009, 12:08 PM
#7
Re: New
#include <iostream>
using namespace std;
int main()
{
int x = 5;
int y = 7;
std::endl;
std::cout << x + y << " " << x * y;
std::end;
char response;
std::cin >> reponse;
return 0;
}
I hope that's correct. I'm still getting the error. I'm sorry ><.. I feel stupid lol..
Last edited by Vaildinfection; March 10th, 2009 at 12:14 PM.
-
March 10th, 2009, 12:18 PM
#8
Re: New
Originally Posted by Vaildinfection
#include <iostream>
using namespace std;
int main()
{
int x = 5;
int y = 7;
std::endl;
std::cout << x + y << " " << x * y;
std::end;
char response;
std::cin >> reponse;
return 0;
}
I hope that's correct. I'm still getting the error. I'm sorry ><.. I feel stupid lol..
No it isn't correct. Have you been reading the replies at all? By the way, don't bother with "using namespace std" if you are going to qualify the names with "std::" anyway. That is just going to cause you trouble eventually and it is not a good idea to have this using declaration at the top of the file like that. The std::endl has to be inserted into the stream not written on a completely separate line as a completely separate statement. Please mark this thread resolved when you have figured it out.
-
March 10th, 2009, 12:19 PM
#9
Re: New
Originally Posted by Vaildinfection
I hope that's correct. I'm still getting the error.
Well, if you are getting an error, it surely is not correct
The problem is that you are still not spelling std::endl correctly in one place.
By the way, please post your code in [code][/code] bbcode tags.
EDIT:
Oh yes, kempofighter's point is good too. As for the other point, note that using namespace std is a using directive, not a using declaration.
-
March 10th, 2009, 12:25 PM
#10
Re: New
Originally Posted by Vaildinfection
#include <iostream>
using namespace std;
int main()
{
int x = 5;
int y = 7;
std::endl;
std::cout << x + y << " " << x * y;
std::end;
char response;
std::cin >> reponse;
return 0;
}
I hope that's correct. I'm still getting the error. I'm sorry ><.. I feel stupid lol..
You were closer your first effort. Also, in both your efforts, you missed the l in your second endl.
Either,
Code:
#include <iostream>
int main()
{
int x= 5;
int y= 7;
std::cout << std::endl;
std::cout << x + y << " " << x * y;
std::cout << std::endl;
char response;
std::cin >> response;
return 0;
}
or
Code:
#include <iostream>
using namespace std;
int main()
{
int x= 5;
int y= 7;
cout << endl;
cout << x + y << " " << x * y;
cout << endl;
char response;
cin >> response;
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|