How Void Pointer behave differently in C & C++
Duration: 10 min
This video lesson is available to enrolled students.
Inside: a video lesson and guided study material.
Module outline
- TCS One Shot Free Videos & Notes: TCS Preparation
- 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
- 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
- New Pattern-Verbal Ability (Foundation Section): Sentence Completion (Fill in the blanks), English Writing Ability
- 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
- Advanced Quantitative Ability: TCS NQT Advanced Quantitative Ability
- Advanced Reasoning Ability: TCS NQT Advanced Reasoning Ability
- 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
- TCS Full Length Mock Test:
- TCS Interview & Resume Prep: MR & HR Interview Preparation, TCS Interview Preparation, Mock Interview, Interview Recordings, Resume Preparation, Resume Review
- Mega Test:
- Grand Test:
AI summary & chapters
AI Summary
An AI-generated summary of this video lecture.
This educational video, presented by Yash Jain from Knowledge Gate Eduventures, is a comprehensive tutorial on the application of void pointers in C and C++. The lecture begins with an introduction to the topic, using a title slide that displays the C and C++ logos and the text 'Application of Void pointer'. The instructor then transitions to a code-based explanation, presenting two code snippets side-by-side: one in C and one in C++. The core of the lesson focuses on the incompatibility between `void *` and `char *` pointers. The instructor demonstrates that in C++, a direct assignment like `char *ptr2 = ptr1;` where `ptr1` is a `void *` pointer will result in a compilation error due to the strict type checking. This is contrasted with C, where such a conversion is allowed implicitly. The video provides a practical demonstration using an online C++ compiler, showing the exact error message: 'error: invalid conversion from 'void*' to 'char*' [-fpermissive]'. To resolve this, the instructor shows the correct method: explicit type casting, writing `ptr2 = (char*)ptr1;`. The video concludes with a 'Thanks' slide, providing contact information for the course provider.
Chapters
0:00 – 2:00 00:00-02:00
The video opens with a title slide for a programming lecture. The slide features a dark background with green and white C++ code floating around. The main title is 'C++ PROGRAMMING' in large white letters, with 'By YASH JAIN' in the top right corner. The slide also includes a graphic of a computer monitor with the C and C++ logos and the text 'Application of Void pointer'. The instructor, Yash Jain, is visible in a small window in the bottom right corner. The slide also contains a copyright notice for 'KNOWLEDGE GATE EDUVENTURES' and a call to action to download the KG app or visit their website.
2:00 – 5:00 02:00-05:00
The video transitions to a code demonstration. The screen is split into two sections, each showing a C++ code snippet. The left snippet is labeled 'C' and the right is labeled 'C++'. Both snippets contain the same code: `#include <stdio.h>`, `int main()`, `{`, `void *ptr1;`, `char *ptr2;`, `ptr2 = ptr1;`, `return 0;`, `}`. The instructor explains that in C++, this code will not compile due to a type mismatch. He then writes on the screen, adding `char *ptr;` and `int *ptr;` to illustrate the concept of type casting. The instructor's voiceover explains that a `void *` pointer can point to any data type, but it cannot be directly assigned to a pointer of a specific type like `char *` without an explicit cast.
5:00 – 9:45 05:00-09:45
The instructor continues the demonstration, focusing on the C++ code snippet. He highlights the line `ptr2 = ptr1;` and explains that this is an invalid conversion. He then shows the correct way to perform the conversion by adding an explicit cast: `ptr2 = (char*)ptr1;`. The video then cuts to a screen recording of an online C++ compiler, where the instructor types the code and runs it, showing the compilation error: 'error: invalid conversion from 'void*' to 'char*' [-fpermissive]'. He then adds the cast, and the code compiles successfully. The video ends with a 'Thanks' slide, providing contact information for the course provider, including a Telegram group and an email address.
The video provides a clear and practical lesson on a fundamental concept in C++ programming: the use of void pointers. It effectively contrasts the behavior of C and C++ when dealing with type conversions, highlighting the stricter type safety in C++. The instructor uses a combination of visual aids, code examples, and a live coding demonstration to explain the problem and its solution. The key takeaway is that while a `void *` pointer can store the address of any data type, it must be explicitly cast to a specific pointer type before it can be used to access the data, a crucial rule for writing safe and portable C++ code.

