C++ Program For get vs getline

Master C++ with Real-time Projects and Kickstart Your Career Start Now!!

Program 1

// get and getline method
#include<iostream>
#include<fstream>
#define clrscr() system("cls")
using namespace std;
int main()
{
    char name[20];
    char college[20];
    clrscr();
    cout<<"\nEnter your Name:";
    cin.getline(name,20);
    cout<<"\nEnter your College Name:";
    cin.getline(college,20);
    cout<<"\nName: "<<name;
    cout<<"\nCollege: "<<college;
    return 0;
}

 

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *