tags:

views:

148

answers:

4

I have tried everything, this is my first C++ program and it not coming out right. I am receiving two error message. error7:1 warning: character constan too long for its type. and 7:error: expe

//My first C++ program
#include <iostream>
int main():
{
    "-std::cout << "I will get it" << -std::cout::end1";
    "-std::cout << "I hope so" << -std::end1;
    return(0);
}
+11  A: 

Your code should be fixed like so:

#include <iostream>
int main()
{
    std::cout << "I will get it" << std::endl;
    std::cout << "I hope so" << std::endl;
    return 0;
}
Yuval A
+3  A: 

Your quoting is entirely wrong and you have a spurious ":" character after main(). You also have some extra '-' characters that you don't need. Finally, in one case you specified std::end1 where you want std::endl and in the other case you specified std::cout::end1 (a '1' where you want a 'l') std::endl. Thanks to Scottie T for that catch.

I believe you want:

//My first C++ program
#include <iostream>
int main()
{
    std::cout << "I will get it" << std::endl;
    std::cout << "I hope so" << std::endl;
    return(0);
}
Eddie
There shouldn't be a colon after main(), and the endl should be std::endl, not std::cout::end1 or std::end1 (not the l instead of the 1.)
jasedit
l/1 strikes again!
Scottie T
I fixed the typos. Didn't catch all of those.
Eddie
@Scottie T: Huh? What do you mean?
Eddie
@Eddie: you kept a typo "end1" instead of "endl"
Yuval A
Updated my answer to credit you and to point out the '1' to 'l' typo, which is not obvious! Thanks for the catch.
Eddie
A: 

It looks like you are adding punctuation to the examples. In programming languages, you must type exactly what you are given.

'int main()'

is not the same as

int main()
Thomas L Holaday
A: 

Also, you can declare

using namespace std;

before

int main()

and you won't need to type that std:: every time.

Martin Janiczek