c++ script help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zerobinary
    New Member
    • Aug 2007
    • 23

    #1

    c++ script help

    I got error like this is bloodshed dev c++
    13 C:\Documents and Settings\Admini strator\Desktop \heros.cpp expected unqualified-id before '}' token
    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
        string title= "the great";
        typedef int revolution;
        revolution heros;
        cout<<"Enter your name and you will be hero";
        while(cin>>heros)
        {
                         cout<<"You are" + heros+title.
                       return 0;  
                       }
                       return 0;
    }
  • zerobinary
    New Member
    • Aug 2007
    • 23

    #2
    I got a problem
    cout<<"You are" + heros+title; how come it won't display that line.
    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
        string title= "the great";
        typedef int revolution;
        revolution heros;
        cout<<"Enter your name and you will be hero";
        while(cin>>heros)
        {
                         cout<<"You are" + heros+title;
                       return 0;  
                       }
                       return 0;
    }

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      This code:
      [quote=zerobinar y]
      cout<<"You are" + heros+title;
      [/code]

      should be:
      [code=cpp]
      cout<<"You are " << heros << title;
      [/code];

      As to why the line is not displaying at all, is because heros is an int. So as long as your name is 42, or some such, the line will display,albeit incorrectly.

      Comment

      • zerobinary
        New Member
        • Aug 2007
        • 23

        #4
        How is that
        but with the reutrn value with 1 instead of 0 i don't c a difference
        Is there a difference between the value of 0 and 1
        Code:
        #include <iostream>
        #include <string>
        using namespace std;
        int main()
        {
            string title= " the great";
            typedef string revolution;
            revolution heros;
            cout<<"Enter your name and you will be hero:\n";
            while(cin>>heros)
            {
                             cout<<"You are "+ heros + title <<"\n";
                             system("pause");
        return 1;
                             }
        
                             return 0;
                             
        }

        Comment

        • zerobinary
          New Member
          • Aug 2007
          • 23

          #5
          what difference will it make, if I change the return value of the loop from 0 to 1.
          and how do u include the last name in the app .
          I mean the want the output to be sth like this
          you are xxx cool the great
          I can't make a spacing between xxx and cool
          don't want to use \t space too much

          Comment

          • zerobinary
            New Member
            • Aug 2007
            • 23

            #6
            how do u change it so the user can decided whatever or not to enter their last name
            Code:
            #include <iostream>
            #include <string>
            using namespace std;
            int main()
            {
                string title= " the great";
                typedef string revolution;
                revolution heros;
                revolution rocks;
                cout<<"Enter your first name and last name and you will be hero:\n";
                while(cin>>heros>>rocks)
                {
                                 cout<<"You are "+heros<<"\ "+rocks+ title <<"\n";
                                 system("pause");
            return 1;
                                 }
            
                                 return 0;
                                 
            }

            Comment

            Working...