Error in C++, help meehh, lmao

Discussion in 'General Discussion / Real life stuff' started by _Lovell_, Jan 27, 2018.

  1. _Lovell_

    _Lovell_ AKA Kali ;) Donator

    Messages:
    64
    Likes Received:
    8
    Minecraft:
    Denzel_Lovell
    So i was just coding around and i wanted to do something, so i decided to make a story, so first of all i typed:

    #include <iostream>
    using namespace std;

    int main()
    {
    int Name;
    cout << "\nENTER YOUR NAME: ";
    cin >> Name;
    cout << "Hello " << Name << ", welcome to the story!";

    return 0;
    }

    So when i run this code i put my name "Kali" and its suppose to say "Hello Kali, welcome to the story" but instead of that it says "Hello 0, welcome to the story". Can anyone help me with this problem?
     
  2. Embracive

    Embracive Former Мod+ Donator

    Messages:
    714
    Likes Received:
    993
    Minecraft:
    Embracive
    What is the code's purpose? Is it for an MC adventure map, or?
     
  3. _Lovell_

    _Lovell_ AKA Kali ;) Donator

    Messages:
    64
    Likes Received:
    8
    Minecraft:
    Denzel_Lovell
    Nah, im bored, im just gonna make a story, like, you read the story im typing in and questions is gonna come and you gonna answer but i need to fix that problem first
     
  4. ItsJerry

    ItsJerry DEAD SERVER!!! LMAO!!! Staff Member Owner

    Messages:
    3,116
    Likes Received:
    21,913
    Minecraft:
    ItsJerry
    I have 0 experience with C++ but why is Name an int

    shouldn't it be "string Name;"
     
    TwageTomato likes this.
  5. _Lovell_

    _Lovell_ AKA Kali ;) Donator

    Messages:
    64
    Likes Received:
    8
    Minecraft:
    Denzel_Lovell
    No, it needs to be a variable

    ihh.. it actually worked, thanks
     
    Last edited by a moderator: Jan 27, 2018
  6. MC_Scout

    MC_Scout Fearless Leader Staff Member Manager

    Messages:
    7,160
    Likes Received:
    13,436
    Minecraft:
    MC_Scout
  7. _Lovell_

    _Lovell_ AKA Kali ;) Donator

    Messages:
    64
    Likes Received:
    8
    Minecraft:
    Denzel_Lovell
  8. TwageTomato

    TwageTomato Former Mod Donator

    Messages:
    977
    Likes Received:
    1,413
    Minecraft:
    Twage
    You may also need to #include<string> up at the top of the program, otherwise some less flexible compilers may yell at you because they don't know what the hell a string is by default.
     
  9. _Lovell_

    _Lovell_ AKA Kali ;) Donator

    Messages:
    64
    Likes Received:
    8
    Minecraft:
    Denzel_Lovell
    Ok, thanks, i may need some more help, could you add me in discord? Kali#7005