Mirixy17 / MindPower

1 stars 0 forks source link

ne razumijem getline svrhu #16

Closed Mirixy17 closed 3 years ago

Mirixy17 commented 3 years ago

I JEDAN I DRUGI KOD ISPISUJU ISTO

#include <iostream>
#include <string>

int main()
{
    std::string fullName;
    {
        std::cout << "Type your full name: ";
    }
    std::cin >> fullName;
    {
        std::cout << "Your name is: " << fullName;
    }
}

#include <iostream>
#include <string>

int main()
{
    std::string fullName;
    {
    std::cout << "Type your full name: ";
    }
    std::getline(std::cin, fullName);
    {
    std::cout << "Your name is: " << fullName;
}
    }

OVI ISTO; U CEMU JE BIT?

#include <string>  
#include <iostream>

int main()
{
    std::string rijec;
    std::cin >> rijec;
    for (int broj = 0; broj < rijec.size(); broj++)
    {
        std::cout << rijec.at(broj) << "\n";
    }
}

#include <string>  
#include <iostream>

int main()
{
    std::string rijec;
    std::getline(std::cin, rijec);
    for (int broj = 0; broj < rijec.size(); broj++)
    {
        std::cout << rijec.at(broj) << "\n";
    }
}

NI OVDJE

#include <iostream>     
int main () {
  char name[256], title[256];

  std::cout << "Please, enter your name: ";
  std::cin.getline (name,256);

  std::cout << "Please, enter your favourite movie: ";
  std::cin.getline (title,256);

  std::cout << name << "'s favourite movie is " << title;

  return 0;
}

#include <iostream>    

int main() {
    char name[256], title[256];

    std::cout << "Please, enter your name: ";
    std::cin >> name;

    std::cout << "Please, enter your favourite movie: ";
    std::cin >> title;

    std::cout << name << "'s favourite movie is " << title;

    return 0;
}
lukarolak commented 3 years ago

http://letmegooglethat.com/?q=What+is+the+difference+between+std%3A%3Agetline+and+std%3A%3Acin