Part 1 - Dive Deep in cin.getline() function in C++

Duration: 11 min

This video lesson is available to enrolled students.

Return to /learn/TCS-NQT-PREPARATION/advanced-coding/programming-in-c/c-mcqs-by-yash-sir/asset-part-1-dive-deep-in-cingetline-function-in-c after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. TCS One Shot Free Videos & Notes: TCS Preparation
  2. Numerical Ability (Foundation Section): Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Sequence and Series (Series), Speed Time and Distance, Percentage, Average, Powers and Exponents (Surds and Indices), Algebra, Probability, Profit and Loss, Simple Interest and Compound Interest, Time and Work, Pipe and Cistern, Mensuration and Geometry, Mental Ability, Age Problems, Statistics, Arithmetic, Partnership, Speed Mathematics and Basic Mathematics
  3. Reasoning Ability (Foundation Section): Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Seating Arrangements, Blood Relations, Directions (Direction Test), Analytical Reasoning (Counting Figures Reasoning), Puzzle Solving (Puzzles), Calendar, Clock, Cubes & Dices, Selection Decision Table (Decision Making), Crypt Arithmetic, Venn Diagram, Data Arrangement, Inequality, Analogy, Ranking, Order and Sequence, Logical Sequence Of Words
  4. New Pattern-Verbal Ability (Foundation Section): Sentence Completion (Fill in the blanks), English Writing Ability
  5. Old Pattern-Verbal Ability (Foundation Section): Vocabulary, Noun, Subject Verb Agreement (Verb Noun Agreement), Adjectives, Tenses, Pronoun, Preposition, Articles, Direct and Indirect Speech, Conjunction, Modals, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Correction (Error Correction), Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Verbal Analogy (Word Based Analogy), Active Passive Voice (Voice), Determiner, Facts, Inference and Judgements, Adverb, Cloze Test (Cloze Passage), Sentence Construction, Verb
  6. Advanced Quantitative Ability: TCS NQT Advanced Quantitative Ability
  7. Advanced Reasoning Ability: TCS NQT Advanced Reasoning Ability
  8. Advanced Coding: Coding Questions by Yash Sir, C Programming by Yash Sir, Python for Placements by Yash Sir, DSA using Python, Object Oriented Programming (OOPS), Programming in C++, Java
  9. TCS Full Length Mock Test:
  10. TCS Interview & Resume Prep: MR & HR Interview Preparation, TCS Interview Preparation, Mock Interview, Interview Recordings, Resume Preparation, Resume Review
  11. Mega Test:
  12. Grand Test:
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This educational video provides a comprehensive tutorial on the C++ getline function. The lecture begins with an introduction to the function, explaining that it is a standard library function used to read a string or a line from an input stream, and that it is part of the <string> header. The instructor then details the two primary syntaxes: getline(ch) and getline(str), and explains that the function extracts characters from an input stream until a delimiting character is encountered, appending them to a string object. The video transitions to a practical demonstration using an online C++ compiler, where the instructor writes and executes code to show how getline works with a character array. The code prompts the user for a name, reads the input using cin.getline, and then prints the entered name, demonstrating the function's ability to handle spaces. The video concludes with a final screen showing the instructor and the 'KGYT' logo.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The video opens with a title slide for a lecture on "Getline In C++". The slide features a blue background with an illustration of two people and a computer screen displaying the word "string". The instructor, visible in a small window in the bottom right, begins the lecture. A copyright notice for "KNOWLEDGE GATE EDUVENTURES" is displayed at the bottom of the screen. The instructor introduces the topic of the getline function in C++.

  2. 2:00 – 5:00 02:00-05:00

    The presentation shifts to a blackboard-style slide. The instructor explains the two syntaxes for the getline function: getline(ch) and getline(str). He defines the function as a standard library function used to read a string or a line from an input stream. He emphasizes that it is part of the <string> header. The instructor then writes the necessary include statements on the board: #include <iostream>, #include <string>, and #include <stdio.h>, explaining that these are required to use the function.

  3. 5:00 – 10:00 05:00-10:00

    The instructor continues on the blackboard, providing a detailed explanation of the getline function's behavior. He states that it extracts characters from the input stream and appends them to a string object until a delimiting character is encountered. He also notes that the previously stored value in the string object will be replaced by the new input. The syntax is clearly written as: istream& getline (istream& is, string& str);. To illustrate the process, he draws a diagram showing a source (input stream) and a destination (string object), with an arrow indicating the flow of data.

  4. 10:00 – 11:26 10:00-11:26

    The video transitions to a screen recording of an online C++ compiler. The instructor writes a complete program to demonstrate the use of getline with a character array. The code includes #include <iostream> and using namespace std;. The main function declares a character array str[20], prompts the user with "Enter Your Name:::", and then uses cin.getline(str, 20) to read the input. The program then prints the entered name. The instructor runs the code, and the output shows the name "Yash Jain" being successfully read and printed, confirming the function's operation. The video ends with a final screen showing the instructor and the KGYT logo.

The video provides a clear and structured lesson on the C++ getline function. It begins with a theoretical explanation of the function's purpose, syntax, and required headers, using a blackboard to illustrate the concept. This is followed by a practical, hands-on demonstration in an online compiler, which solidifies the learning by showing the function in action. The progression from theory to practice effectively teaches students how to use getline to read entire lines of text, including those with spaces, which is a common requirement in C++ programming.

Loading lesson…