C_63 Strings in C-part 2 | Read a String using scanf and gets function

Jenny's Lectures CS IT
27 Jul 202118:05

Summary

TLDRThe video script is an in-depth discussion on strings in the C programming language. It covers the basics of what a string is, how to declare and initialize strings, and the importance of null characters. The script explains compile-time data, the use of functions like 'scanf' and 'gets', and their differences, emphasizing the risks of buffer overflow. It also demonstrates how to read a string using 'scanf' and the advantages of using both functions. The video aims to educate viewers on the correct practices to avoid common pitfalls when handling strings in C.

Takeaways

  • 😀 The video discusses the basics of strings in the C programming language, including how to declare, initialize, and read strings.
  • 📝 It explains that strings in C are arrays of characters and emphasizes the importance of the null terminator character at the end of a string.
  • 💡 The video covers the use of the 'scanf' function to read strings from the user input, including the format specifier '%s'.
  • 🔍 It demonstrates how to use the 'gets' function to read a string, but also mentions its deprecation due to security risks.
  • 👍 The script highlights the difference between character arrays and strings, and the need to allocate memory for strings.
  • 🚫 The video warns against buffer overflow, a common security vulnerability when dealing with strings and arrays.
  • 🔑 It shows how to use the 'printf' function with '%s' to print strings, and the importance of handling memory correctly.
  • 🔄 The script touches on the concept of memory allocation for strings and the potential risks of overwriting memory.
  • 🛠️ It provides an example of how to enter a string using 'scanf' and 'gets' functions and the associated risks.
  • 📚 The video mentions the importance of understanding computer memory when working with strings to avoid unsafe practices.
  • ✅ Finally, it suggests that using 'fgets' is a safer alternative to 'gets' and hints at covering more about 'fgets' in a separate video.

Q & A

  • What is the main topic of the video script?

    -The main topic of the video script is discussing strings in C programming, including how to declare, initialize, and read strings at runtime.

  • What is the difference between character array and string as mentioned in the script?

    -The script explains that a character array is just an array of characters, while a string is a character array that is null-terminated, indicating the end of the string.

  • How does the script define a string in C?

    -In the script, a string is defined as a character array that is null-terminated, which means it ends with a null character ('\0').

  • What is the purpose of the null character in a string?

    -The null character ('\0') in a string serves as an indicator to signal the end of the string, which is important for functions that process strings.

  • What is the role of the 'scanf' function in reading strings as discussed in the script?

    -The 'scanf' function is used to read strings at runtime. However, it's mentioned that 'scanf' should not be used with '%s' to read strings due to the risk of buffer overflow.

  • What is buffer overflow and why is it a concern in the script?

    -Buffer overflow is a situation where more data is written to a block of memory, or buffer, than it can hold, which can lead to data corruption and security vulnerabilities. The script highlights this as a risk when using 'scanf' to read strings.

  • What alternative to 'scanf' is suggested in the script for reading strings?

    -The script suggests using 'fgets' as an alternative to 'scanf' for reading strings, as it is safer and can prevent buffer overflow.

  • How does the script explain the use of 'fgets' to read strings?

    -The script explains that 'fgets' can be used to read an entire line, including spaces, until a newline character is encountered, making it a safer choice for string input.

  • What is the significance of the 'gets' function mentioned in the script?

    -The 'gets' function is mentioned as a deprecated function that was used to read strings. It is highlighted as unsafe due to its potential to cause buffer overflow and is no longer recommended for use.

  • How should one declare a string in C according to the script?

    -The script suggests declaring a string in C by specifying the type as 'char' and initializing it with a set of characters enclosed in double quotes, followed by a null character at the end.

  • What is the importance of understanding memory allocation when working with strings in C?

    -Understanding memory allocation is crucial when working with strings in C to avoid issues like buffer overflow and to ensure that the correct amount of memory is allocated for the string data.

Outlines

00:00

📘 Basics of C Strings

The script introduces the basics of strings in C programming, explaining how to declare, initialize, and manipulate them. It discusses the importance of null-terminated strings and the role of the '\0' character in C. The video also covers the use of functions like 'scanf' and 'gets' for reading strings, highlighting the risks of buffer overflow. The script emphasizes the need to understand memory allocation and the difference between character arrays and strings in C.

05:02

🔍 Reading and Storing Strings in C

This paragraph delves into the process of reading and storing strings in C. It explains how characters are automatically stored at the next position in memory and how pressing 'Enter' signifies the end of the string input. The script clarifies that the 'gets' function is unsafe due to buffer overflow risks and advises against its use. It also discusses the importance of specifying the address for each character entered and the concept of memory allocation for storing characters, including the maximum size limit.

10:02

🚫 Buffer Overflow and String Handling

The script addresses the dangers of buffer overflow when handling strings in C. It explains that writing beyond the allocated memory for a string can lead to program crashes or security vulnerabilities. The video emphasizes the importance of checking buffer sizes and the risks associated with using functions like 'gets'. It also discusses the use of 'scanf' with format specifiers as a safer alternative for reading strings and the importance of using the correct format specifiers to avoid overflow.

15:03

🛠 Best Practices for String Input in C

The final paragraph focuses on best practices for handling string input in C. It advises against using 'gets' due to its lack of buffer size control and recommends using 'fgets' instead. The script also discusses the importance of understanding the memory allocated for strings and the risks of buffer overflow. It suggests using fixed-size buffers and checking for buffer overflow to ensure program safety. The video concludes with a reminder of the importance of these concepts and hints at further discussion in future videos.

Mindmap

Keywords

💡Strings

In the context of the video, 'strings' refer to a sequence of characters used in programming to represent text. They are fundamental data types in C and C++ programming languages. The script discusses how to declare, initialize, and manipulate strings, which is central to the video's theme of learning programming.

💡Declaration

Declaration in programming is the process of telling the compiler about the variable's existence and type. The script mentions 'how to declare a string,' which is an essential concept for understanding how variables, including strings, are set up in the code.

💡Initialization

Initialization is the process of assigning an initial value to a variable. The video script discusses 'how to initialize a string,' which is crucial for setting up the starting state of a string in a program.

💡Compile-time

Compile-time refers to the phase in program execution where the source code is translated into machine code by a compiler. The script mentions 'compile-time' in the context of declaring and initializing strings, indicating the moment when the string's memory allocation and setup occur.

💡Data Function

The 'data function' mentioned in the script likely refers to a function that deals with data, such as reading or writing data. In the context of strings, this could involve functions that manipulate or process the string data within a program.

💡Character Array

A 'character array' is a data structure that can store a sequence of characters. In the script, it is implied that strings are represented as character arrays in C and C++, where each element of the array holds a character of the string.

💡Null Character

The 'null character', often represented as '\0', signifies the end of a string in C and C++. The script mentions the importance of the null character in determining the end of a string, which is a critical concept for string manipulation and processing.

💡Overflow

In the context of the script, 'overflow' refers to the situation where a program tries to store more data in a buffer than it can hold, potentially overwriting adjacent memory. The video warns against buffer overflow, which is a common security vulnerability in programming.

💡scanf Function

The 'scanf function' is a standard input function in C that reads formatted input from the standard input (usually the keyboard). The script discusses using 'scanf' to read string data, which is a common practice in C programming for user input.

💡Garbage Value

A 'garbage value' is an undefined or unintended value that can appear in a program due to improper handling of memory or variables. The script mentions avoiding garbage values when dealing with strings, which is important for maintaining the integrity of data.

💡Memory Allocation

Memory allocation in programming is the process of reserving a block of memory for use by a program. The script talks about the automatic memory allocation for strings, which is a key aspect of how strings are managed in the C programming language.

Highlights

Discussing strings in C++

Basics about strings, how to declare, initialize, and use them

Difference between character arrays and strings

Using the 'scanf' function to read strings

The importance of null characters in strings

Automatic memory allocation for strings by the compiler

How to read a string using 'scanf' function

Entering a string and storing it in memory

The concept of buffer overflow and its risks

Using 'fgets' function as an alternative to 'scanf'

Reading a string without considering white spaces

The role of memory allocation in string handling

Difference between 'scanf' and 'fgets' functions

Practical demonstration of reading strings in C++

Understanding the risks associated with buffer overflow

The importance of proper memory management when working with strings

Conclusion and summary of key points about strings in C++

Transcripts

play00:00

सो इन द सीरीज ऑफ लर्निंग प्रोग्रामिंग इन

play00:02

सी वी आर डिस्कसिंग स्ट्रिंग्स इन सी वी

play00:04

हैव डिस्कस व्हाट बेसिक्स अबाउट स्ट्रिंग

play00:06

लाइक व्हाट इज स्ट्रिंग हाउ टू डिक्लेयर अ

play00:08

स्ट्रिंग हाउ टू इनिला इज अ स्ट्रिंग एट

play00:09

कंपाइल टाइम दैट वी हैव डिस्कस इन

play00:11

प्रीवियस वीडियो एंड सम इंपोर्टेंट पॉइंट

play00:13

अबाउट स्ट्रिंग्स आल्सो सो वन क्वेश्चन

play00:16

फॉर यू इ बिफोर स्टार्टिंग दिस वीडियो वन

play00:18

क्वेश्चन इज यू हैव टू टेल मी इन कमेंट

play00:20

बॉक्स इज स्ट्रिंग अ डेटा टाइप इन सी यस र

play00:22

नो यू हैव टू टेल मी इन कमेंट बॉक्स राइट

play00:25

नाउ लेट्स स्टार्ट विद द नेक्स्ट नो पार्ट

play00:28

इन स्ट्रिंग्स इन सी इन दिस यू विल सी

play00:30

व्हाट हाउ टू इनिश इइ अ स्ट्रिंग एट रन

play00:32

टाइम और यू कैन से हाउ टू रीड अ स्ट्रिंग

play00:35

सो यू कैन रीड और यू कैन इनिश इइ अ

play00:37

स्ट्रिंग एट रन टाइम यूजिंग अ स्टैंडर्ड

play00:40

फंक्शन व्हाट इज दैट फंक्शन स्कन एफ एज

play00:43

वेल एज गेट एस टू फंक्शंस आर देयर स्कन एफ

play00:47

एंड गेट एस गेट कैर इज आल्सो देयर बट

play00:50

ओबवियसली गेट कैर कैन आल्सो रीड ओनली वन

play00:52

कैरेक्टर सो वी हैव टू पुट दैट इनटू लूप

play00:54

राइट सो वी विल डिस्कस दीज टू टू रीड अ

play00:58

स्ट्रिंग एट रन टाइम और टू इ लाइ स्ट्रिंग

play01:00

एट रन टाइम वी विल डिस्कस द ड्रॉ बैक्स ऑफ

play01:02

बोथ द फंक्शन एज वेल एज सम एडवांटेजेस ऑफ

play01:04

यूजिंग बोथ द फंक्शंस राइट फर्स्ट वी विल

play01:07

डिस्कस हाउ टू रीड अ स्ट्रिंग यूजिंग

play01:09

स्कैन अ फंक्शन राइट स्ट्रिंग इज व्हाट

play01:12

इट्स नथिंग बट अ कैरेक्टर एरे व्हिच इज

play01:14

एंडिंग विद नल कैरेक्टर राइट

play01:17

सी आई होप द डिफरेंस इज क्लियर बिटवीन

play01:21

कैरेक्टर एरे एंड स्ट्रिंग इफ आई डिक्लेयर

play01:23

समथिंग लाइक दिस अ स्ट्रिंग लाइक कैर अ

play01:26

स्ट्रिंग नेम इज s1 आई एम टेकिंग राइट एंड

play01:30

हेयर द साइज इज

play01:32

10 राइट एंड हेयर आई एम गोइंग टू स्टोर

play01:36

जेनी दिस इज हाउ वी कैन इनिला इज अ

play01:39

स्ट्रिंग एट कंपाइल टाइम य यूजिंग अ

play01:41

स्ट्रिंग लीटल व्हाट एवर यू आर टिंग इन

play01:43

डबल कोर्स दैट इज कंसीडर्ड एज अ स्ट्रिंग

play01:45

ऑटोमेटिक कंपाइलर विल डू व्हाट हाउ टू

play01:48

स्टोर दिस 10 बाइट शुड बी एलोकेटेड

play01:53

हियर राइट सपोज मेमोरी इज फ्रॉम 1000

play01:58

टू

play02:02

1009 एंड दिस s1 इज द नेम ऑफ द स्ट्रिंग

play02:05

एंड इट इज कंटेनिंग व्ट बेस एड्रेस और यू

play02:08

कैन से द एड्रेस ऑफ द फर्स्ट बाइट ऑफ दिस

play02:10

कैरेक्टर एरे दिस कंप्लीट इज व्हाट

play02:12

कैरेक्टर एरे एंड हेयर आई एम गोइंग टू सो

play02:14

व्ट जेई डब एंडवा दिस इज व्हाट अ स्ट्रिंग

play02:19

सो कंपाइलर ऑटोमेटिक विल अपेंड विल य नो

play02:23

पुट अ नल कैरेक्टर आफ्टर दिस स्ट्रिंग इट

play02:27

मींस दिस कंप्लीट इज कैरेक्टर एरे हेयर वी

play02:29

आर हैविंग सम गार्बेज वैल्यू बट इन दिस

play02:31

कैरेक्टर एरे स्ट्रिंग इज व्हाट ओनली दिस

play02:34

वन वंस कंपाइलर विल फाइंड दिस नल कैरेक्टर

play02:37

मींस इट इज एंड ऑफ स्ट्रिंग एंड ऑफ

play02:41

स्ट्रिंग राइट सो दिस इज व्ट स्ट्रिंग बट

play02:44

या दिस इज कैरेक्टर एरे सो दैट इज डिफरेंस

play02:46

स्ट्रिंग वड ऑलवेज बी एंडेड विद अ नल

play02:48

कैरेक्टर अदर वाइज स्ट्रिंग इज जस्ट अ

play02:51

कैरेक्टर एरे और यू कैन से इट्स एरे ऑफ

play02:53

कैरेक्टर राइट सो आई होप यू नाउ गट द

play02:55

डिफरेंस बिटवीन कैरेक्टर एरे और स्ट्रेन

play02:57

यू कैन इफ एनी वन आस्क देन यू कैन टेल विद

play03:00

सम एग्जांपल राइट नाउ राद देन

play03:06

इनिशियर आई एम गोइंग टू रीड दिस यूजिंग

play03:09

स्कैनर फंक्शन

play03:13

राइट सो आई एम जस्ट राइटिंग फर्स्ट ऑफ ऑल

play03:16

लाइक एंटर स्ट्रिंग दैट शुड बी प्रिंटेड

play03:19

ऑन द कंसोल ऑन द आउटपुट स्क्रीन व्हेन यू

play03:22

रन द प्रोग्राम एंड हाउ टू रीड यूजिंग

play03:25

स्कैन एफ सो फॉर्मेट स्पेसिफाई अ स्ट्रिंग

play03:27

इज परसेंटेज s

play03:30

राइट एंड सिंपली हेयर यू हैव टू पास व्हाट

play03:33

नेम ऑफ द स्ट्रिंग

play03:36

s1

play03:58

दैट्ची वी आर हैविंग सपोज इफ वी आर

play04:01

एंटरिंग अ स्ट्रिंग समथिंग लाइक दिस सी

play04:04

व्हेन यू आर गोइंग टू रन देन इट शुड

play04:07

प्रिंट एंटर स्ट्रिंग एंड सपोज आई एम

play04:08

एंटरिंग जेई ड एन वा जन सो हेयर आल्सो वी

play04:12

आर हैविंग ट 3 4 फ फाइव कैरेक्टर्स यू हैव

play04:15

टू प्रिंट फाइव कैरेक्टर्स राइट बट वी आर

play04:18

नॉट यूजिंग एनी लूप अनदर डिफरेंस इज वी आर

play04:20

नॉट यूजिंग एनी एड्रेस ऑफ ऑपरेटर हियर

play04:23

राइट व्हाई एड्रेस ऑफ ऑपरेटर वी आर नॉट

play04:26

प्रोवाइड हियर बिकॉज s1 इज व्हाट एंड इट

play04:29

इज कंटेनिंग 1000 द बेस एड्रेस ऑफ़ दिस

play04:32

कैरेक्टर एरे और यू कैन से द फर्स्ट

play04:33

एड्रेस ऑफ़ दिस दिस वन सो इफ यू हैव

play04:35

एंटर्ड जेनी सो जेनी वुड बी स्टोर्ड

play04:37

समथिंग लाइक दिस जेई डल

play04:39

एवा राइट

play04:41

एंड आफ्टर कंप्लीट ंग दिस अनल कैरेक्टर

play04:46

व्हिच शोज दैट हेयर इट इज़ एंडिंग ऑफ़ द

play04:48

स्ट्रिंग एंड हेयर मे बी सम गार्बेज

play04:50

वैल्यू आर देयर वी डोंट नो एनी एनी

play04:51

गार्बेज वैल्यू इज देयर राइट सो दिस इज़

play04:53

कैरेक्टर अरे दिस इज़ व्हाट स्ट्रिंग सो

play04:55

नाउ व्हेन यू पास s1 मींस यू आर पासिंग

play04:58

1000 दैट इज एड्रेस ऑफ द फर्स्ट वन एड्रेस

play05:01

ऑफ़ द फर्स्ट बाइट द फर्स्ट लोकेशन सो जे

play05:04

वुड बी स्टोर्ड हियर राइट एंड e वुड डेफ

play05:07

बी ऑटोमेटिक स्टोर्ड एट द नेक्स्ट पोजीशन

play05:09

देन ए देन ए देन वा एंड देन एट लास्ट

play05:13

व्हेन यू प्रेस

play05:15

एंटर देन व्हाट इट मींस एंड एंड ऑफ द

play05:19

स्ट्रिंग मींस व्हेन यू हैव एंटर्ड व्हेन

play05:21

यू प्रेस एंटर इट मींस इट विल यू नो स्टोर

play05:24

नल कैरेक्टर एट द एंड इट विल शो एंड ऑफ द

play05:27

स्ट्रिंग हियर राइट सो दैट इज वी आर नॉट

play05:30

पासिंग एनी एड्रेस ऑफ ऑपरेटर बिकॉज वी आर

play05:33

ओबवियसली पासिंग द एड्रेस ओनली बाय

play05:35

राइटिंग दिस नेम एव राइट एंड वी आर नॉट

play05:38

यूजिंग एनी फोर लूप वई सो बिकॉज हेयर वी

play05:42

डोंट नीड टूू य नो

play05:44

स्पेसिफाई द एड्रेस फॉर एवरी कैरेक्टर यू

play05:47

आर एंटरिंग राइट सपोज यू आर टेकिंग एन एरे

play05:50

इंट एरे ऑफ साइज फ और

play05:54

10 मींस य आर राइटिंग व्ट एंटर 10

play05:58

एलिमेंट्स ऑफ़ एन एरे वी नो एग्जैक्ट वी

play06:00

हैव टू एंटर 10 एलिमेंट्स 10 एलिमेंट्स इन

play06:03

एरे 10 इंटी जर इन दिस एरे सो एंड वी वर

play06:06

पासिंग एड्रेस फॉर इंडिविजुअल इंटी जर्स

play06:09

इन द एरे राइट मेमोरी लोकेशन फॉर ऑल द 10

play06:12

इंटी जर्स इन फोर लूप बट हेयर इफ सपोज आई

play06:16

एम आस्किंग एंटर ए स्ट्रिंग और एंटर नेम

play06:19

बेसिकली वीी यूज़ अ स्ट्रिंग समथिंग लाइक

play06:21

दिस आई हैव रिटन s1 बट बेसिकली वी यूज़

play06:24

व्हाट टू एंटर सम नेम और दिस काइंड ऑफ़

play06:27

थिंग सो कैर नेम 10 सो हेयर आई एम राइटिंग

play06:31

एंटर नेम सो आई डोंट नो हाउ मेनी

play06:34

कैरेक्टर्स आर देयर इन नेम इट्स नॉट लाइक

play06:36

दैट आई विल स्पेसिफाई एंटर 10 कैरेक्टर्स

play06:37

ऑफ योर नेम नो राइट वी डोंट नो हाउ मेनी

play06:42

कैरेक्टर्स वीी आर गोइंग टू एंटर राइट सो

play06:44

नाउ दिस दिस इज परसेंटेज दिस फॉर्मेट

play06:46

स्पेसिफीज हैज बीन रिटन इन सच अ वे दैट वी

play06:50

डोंट नीड टू पुट दिस स्कैनफ इन टू फोर लूप

play06:53

एंड वी डोंट नीड टू पुट एनी लाइक एड्रेस

play06:54

ऑफ ऑपरेटर यर दैट रीजन आई हैव ऑलरेडी

play06:56

टोल्ड यू राइट नाउ हेयर आल्सो इट विल

play07:01

प्रिंट एंटर

play07:04

नेम राइट नाउ सी ओके ना इफ यू वांट टू

play07:09

प्रिंट दिस स्ट्रिंग देन य सिंपली यूज

play07:11

प्रिंट एफ परसेंटेज एस परसेंटेज एस इ वट

play07:14

फॉर्मेट

play07:30

नेम ट सो ट इट विल प्रिंट यर जई डबल

play07:36

एनवास य कैन रीड यूजिंग स्कन फंक्शन बट ना

play07:40

द ड्र बैक ऑफ

play07:41

दिस इ आई वांट टू एंटर द नेम समथिंग लाइक

play07:46

दिस इ आ एंटरिंग नेम यर

play07:51

लाइक जयंती खत्री जयंती देन स्पेस एंड देन

play07:56

खतरी सो ना व्हाट इट विल स्टोर यर एंड

play08:00

सपोज साइज आई एम टेकिंग साइज शुड बी व्हाट

play08:03

साइज शुड बी व्हाट नंबर ऑफ कैरेक्टर प्लस

play08:06

वन प्लस वन इज फॉर नल कैरेक्टर सो हाउ

play08:09

मेनी कैरेक्टर्स आर देयर 1 2 3 4 5 6 7 8

play08:12

9 10 11 12 13 14 सो 14 कैरेक्टर्स

play08:15

इंक्लूडिंग वाइट स्पेस प्लस वन इज फॉर नल

play08:19

इट शुड बी 15 एटलीस्ट और आई एम टेकिंग

play08:21

मैक्सिमम दैट इज 30 सो दैट यू कैन स्टोर

play08:24

अप टू 30 कैरेक्टर्स राइट सो नाउ द आउटपुट

play08:27

शुड बी जयंती खतरी बट द आउटपुट यू विल गेट

play08:31

ओनली जंती इफ यू आर यूजिंग स्कैनफ टू रीड

play08:36

दिस काइंड ऑफ थिंग व्हाई बिकॉज स्कैनफ विल

play08:40

नॉट कंसीडर्ड वाइट स्पेस इन स्ट्रिंग सो

play08:45

व्हेन यू एंटर देन हाउ इट वुड बी स्टोर्ड

play08:47

हेयर इन दिस वन सपोज इट इज अप

play08:51

टू 30 कैरेक्टर्स 30 ब्लॉक्स मींस द

play08:54

लोकेशन वुड बी अप टू 1029 एंड 1000 इ

play08:57

स्टोर यर सो इट विल स्टोर जे व्हेन यू

play08:59

एंटर जे इट वुड बी स्टोर्ड हियर व्हेन यू

play09:01

प्रेस लाइक ए समथिंग लाइक दिस जे देन इट

play09:04

वुड बी स्टोर्ड हियर ए हेयर

play09:07

वा देन ए ए टी एंड आई एंड नाउ बिफोर

play09:16

राइटिंग खतरी आई एम आई एम प्रोवाइड अ

play09:19

स्पेस स्पेस सो व्हेन यू प्रेस स्पेस देन

play09:23

इट विल नॉट कंसीडर इट स्कैनफ विल नॉट

play09:25

कंसीडर स्पेस इन स्ट्रिंग सो इट विल थिंक

play09:28

दैट इट इज एंड ऑफ द स्ट्रिंग एंड कंपाइलर

play09:30

विल ऑटोमेटिक पुट हियर नल कैरेक्टर सो

play09:34

स्पेस खतरी सो इट इज नॉट गोइंग टू यू नो

play09:37

स्टोर दिस खतरी हेयर हेयर इट शुड बी सम

play09:39

गार्बेज वैल्यू एंड व्हेन यू विल प्रिंट इ

play09:42

इट विल ओनली प्रिंट जयंती सी इट इज नॉट

play09:46

प्रिंटिंग एनी गार्बेज

play09:47

वैल्यू बिकॉज ओबवियसली नेम इज व्ट अ

play09:50

कैरेक्टर एरे ऑफ 30 कैरेक्टर्स सो इट शुड

play09:53

प्रिंट लाइक जयंती एंड रिमेनिंग कैरेक्टर

play09:56

वुड बी सम अ व्ट

play10:01

गार्बेज वैल्यू सो हेयर इट शुड बी सम

play10:04

गार्बेज वैल्यू बट इट इज नॉट प्रिंटिंग

play10:06

गार्बेज वैल्यू वी वांट द एग्जैक्ट आउटपुट

play10:08

ओबवियसली वीी वांट द एग्जैक्ट नेम वी डोंट

play10:10

वांट एनी गार्बेज वैल्यू दैट इज व्हाई

play10:13

कंपाइलर विल ऑटोमेटिक वट पुट दिस नल

play10:17

कैरेक्टर एट द एंड ऑफ द स्ट्रिंग सो व्हेन

play10:18

एवर यू रीड दिस व्हेन यू आर प्रिंटिंग

play10:22

परसेंटेज एस विद परसेंटेजेस दिस फॉर्मेट

play10:24

स्पेसिफाइड इज रिटन समथिंग लाइक दिस इट इज

play10:26

प्रोग्राम समथिंग लाइक दिस राइट

play10:29

सो व्हेन एवर इट विल रीड टिल आई देन इट

play10:31

विल रीड नल कैरेक्टर इट मींस एंड ऑफ

play10:34

स्ट्रिंग इट विल नॉट प्रिंट एनीथिंग च इज

play10:37

बियोंड

play10:38

दिस नल कैरेक्टर राइट सो इट विल ओनली

play10:42

प्रिंट जयंती यर सो दिस इज व्ट वन ड्र बैक

play10:45

ऑफ स्कनर लाइक इफ आई वांट टू प्रिंट जयंती

play10:48

खतरी लांबा और यू कैन से जनीज लेक्चर इज अ

play10:52

यू नो इज बेस्ट चैनल फॉर सीएस एंड आईटी

play10:56

स्टूडेंट सो इट विल नॉट प्रिंट द

play10:59

प्रिंट ओनली द कैरेक्टर्स

play11:02

अंट्स इट विल स्टोर टिल देन इफ यू राइट

play11:06

जयंती एंड लाइक दिस खतरी विदाउट एनी वाइट

play11:09

स्पेस इट्स ओके इट विल प्रिंट जयंती खतरी

play11:14

यर राइट बट इ वाइट स्पेस देन इट विल नॉट

play11:17

स्टोर सो दैट इज वन ड्र बैक ऑफ स्कन स्कन

play11:20

फंक्शन आई होप यू गट इट टू ओवरकम दिस डॉ

play11:23

बैक वी यूज गेटस

play11:25

फंक्शन गेटस विल व्ट रेड द कंप्लीट लाइन

play11:29

इंक्लूडिंग वाइट स्पेस

play11:32

अंट्स अ न्यू लाइन और यू कैन से

play11:36

एंटर राइट टिल देन इट विल रीड द कंप्लीट

play11:39

लाइन सो इफ यू वांट टू रीड द कंप्लीट लाइन

play11:42

देन यूज गेटस फंक्शन या देयर इज वन मोर

play11:44

ड्रॉ बैक दैट इज बोथ फॉर स्कैनफ एंड गेटस

play11:47

दैट वी विल डिस्कस आफ्टर आफ्टर डिस्कसिंग

play11:49

गेटस सो आई होप यू गोट नाउ स्कैनफ फंक्शन

play11:51

एंड इट्स ड्रॉबैक नाउ सी हाउ गेटस फंक्शन

play11:54

वुड बी यूज्ड सेम वी डिक्लेयर अ स्ट्रिंग

play11:58

एंटर नेम एंड हेयर राद देन स्कन एफ आई एम

play12:00

यूजिंग

play12:01

व्हाट गेट एस एंड हेयर यू जस्ट नीड टू पास

play12:06

द नेम ऑफ द स्ट्रिंग हेयर नेम इज व्ट नेम

play12:09

ओनली सो

play12:27

दैट्ची नाउ सी व्हाट शुड बी द आउटपुट ऑफ़

play12:31

दिस थिंग नाउ एंटर नेम एंड आई एम एंटरिंग

play12:33

नेम लाइक समथिंग लाइक

play12:35

दिस जयंती स्पेस खतरी स्पेस लांबा राइट

play12:40

एंड नाउ एंड आफ्टर दैट आई एम प्रेसिंग

play12:42

एंटर राइट सो इट विल स्टोर हेयर जयंती

play12:47

स्पेस खतरी स्पेस लांबा एंड व्हेन एवर यू

play12:52

प्रेस एंटर इट विल स्टॉप रीडिंग एंड

play12:54

ऑटोमेटिक मींस एंड ऑफ स्ट्रिंग एंड एट द

play12:57

लास्ट इट विल पुट व्हाट कंपाइलर विल पुट अ

play13:00

नल कैरेक्टर एट द एंड राइट सो व्हेन वी

play13:03

रीड इट विल प्रिंट जयंती स्पेस खतरी स्पेस

play13:07

लाबा सो दैट इज हाउ यू कैन रीड अ एनटायर

play13:09

लाइन विथ स्पेस एंड एवरीथिंग यूजिंग गेटस

play13:13

फंक्शन राइट सो नाउ इट इज बेटर देन स्कन

play13:17

एफ बट बट ड्रॉ बैक इज व्हाट सी फॉर बोथ

play13:23

स्कैन एफ एंड गेट एस फंक्शन व्हाट इज द

play13:25

ड्रॉ

play13:26

बैक बफर ओवरफ्लो ो बैक नाउ व्हाट इज दिस

play13:30

थिंग सी

play13:32

हेयर इफ आई एम राइटिंग हियर नेम एंड आई एम

play13:35

प्रोवाइड साइज फाइव ओनली

play13:38

राइट इट

play13:40

मींस फोर कैरेक्टर वी कैन स्टोर एंड वन इज

play13:44

फॉर नल कैरेक्टर राइट सो नाउ वी आर

play13:47

एंटरिंग अ नेम एंड हेयर आई एम एंटरिंग सेम

play13:50

जयंती स्पेस खतरी स्पेस लाबा सो इट विल

play13:54

ट्राई टू रीड इट विल ट्राई टू स्टोर द

play13:57

एंटायस स्ट्रिंग

play13:59

लद स्पेस ज लोकेटेड फॉर

play14:03

ओनली टूथ फर 5 ओनली फाइ बाइट्स ओनली फॉर

play14:07

फाइव कैरेक्टर्स एंड वन इज ओबवियसली फॉर

play14:09

इट शुड बी नल सो यू नो अकॉर्डिंग टू द

play14:13

लॉजिक व्ट एवर वी हैव स्टडीड इन स्ट्रिंग

play14:16

ओनली जवाई शुड बी स्टोर्ड एंड लास्ट इट

play14:19

शुड बी व्ट अ नल कैरेक्टर राइट बट हेयर इट

play14:24

विल स्टोर द

play14:28

र स्ट्रिंग यू कैन रन दिस प्रोग्राम सो

play14:30

दिस इज व्हाट ओवरफ्लो इट इज नॉट गोइंग टू

play14:32

चेक द बफर द बफर

play14:35

साइज नाउ मेमोरीज एलोकेटेड ओनली फाइव

play14:38

बाइट्स सो इट इज गोइंग टू स्टोर बियोंड

play14:40

दिस मेमोरी

play14:42

हियर सो व्हाट एवर इज देयर इन दिस मेमोरी

play14:46

इट इज गोइंग टू ओवरराइट दैट थिंग सो दैट

play14:48

इज वेरी रिस्की मे बी सम यू नो वेरी

play14:52

इंपॉर्टेंट इंफॉर्मेशन और सम क्रिटिकल

play14:53

प्रोग्राम इज रिटन दिस बियोंड दिस मेमोरी

play14:56

वी डोंट नो अबाउट द कंप्यूटर मेमोरी

play14:59

सो दैट इट इज गोइंग टू ओवरराइट इट इज

play15:02

गोइंग ट इट विल ट्राई टू ओवरराइट दैट

play15:04

प्रोग्राम एंड इट विल ट्राई टू स्टोर द

play15:06

एनटायर स्ट्रिंग टिल यू एंटर अ न्यू लाइन

play15:09

सो दैट वुड बी वेरी यू नो रिस्की टू यूज

play15:12

इट्स नॉट सेफ इट्स वेरी

play15:14

अनसेफ राइट सो दैट इज वई इट्स रिस्की टू

play15:19

यूज गेटस राइट बिकॉज ऑफ द बफर ओवरफ्लो

play15:23

कंडीशन सेम विद स्कैनफ स्कैनफ विल आल्सो

play15:26

डू सेम थिंग इफ आई मॉडिफाई दिस प्रोग्राम

play15:29

समथिंग लाइक

play15:30

दिस रार देन गेट एस बेटर टू यूज एफ गेट ए

play15:36

दैट आल्सो वी विल डिस्कस इन सेपरेट वीडियो

play15:38

राइट इट इज बेटर टू यूज इट इज बेटर टू यूज

play15:41

देन दिस गेटस एंड स्कन सो हेयर आई एम

play15:43

राइटिंग स्कैन

play15:45

एफ

play15:47

एंड परसेंटेज

play15:49

ए एंड आई एम गोइंग टू पास ओनली नेम यर

play15:54

राइट एंड आई एम गोइंग टू प्रिंट ओके नेम

play15:59

दिस आल्सो विल डू सेम थिंग

play16:02

हेयर आई थिंक फोर कैरेक्टर श इट शुड टेक

play16:06

एंड वन इज फॉर नल राइट एंड इफ आई राइट

play16:11

हेयर जयंती सो द कैरेक्टर्स आर टूथ फर 5 6

play16:16

सेन कैरेक्टर्स एंड वन आल्सो वन वुड बी नल

play16:19

मींस एट राइट सो या इट विल ट्राई टू स्टोर

play16:24

कंप्लीट दिस नेम जयंती एंड इट विल प्रिंट

play16:27

जयंती बट ओनली द बफर साइज फॉर फाइ

play16:30

कैरेक्टर्स सो इट इ आल्सो हैविंग द सेम

play16:33

प्रॉब्लम ऑफ बफर ओवरफ्लो इट इट इ नॉट

play16:36

गोइंग टू चेक द बफर साइज वाइल टेकिंग

play16:39

इनपुट इट इ आल्सो गोइंग टू ओवरराइट इट इ

play16:43

आल्सो गोइंग टू स्टोर दिस थिंग एंड बियोंड

play16:45

दिस लोकेटेड मेमोरी आई होप यू आर गेटिंग

play16:48

माय पॉइंट राइट इ इट कन्फ्यूजिंग नो राइट

play16:53

ओके नाउ सी नाउ ओके इन स्न हैव वन थिंग

play16:59

लाइक हेयर इफ आई राइट

play17:01

परसेंटेज

play17:04

4s नाउ इट मींस इट विल ओनली रीड फोर

play17:08

कैरेक्टर्स यू आर सपोज एट द आउटपुट

play17:12

स्क्रीन यू आर एंटरिंग एंटर नेम जयंती इट

play17:15

विल स्टोर नाउ ओनली जे एवाई ए ओनली फोर

play17:18

कैरेक्टर्स एंड आफ्टर दैट नल कैरेक्टर सो

play17:22

दिस इज वन

play17:23

अल्टरनेटिव बट यली यू हैव टू डू सम हार्ड

play17:26

कोडिंग लाइक आई वांट टू एंटर ओनली

play17:28

कैरेक्टर 15 कैरेक्टर समथिंग लाइक दिस दैट

play17:30

इज नॉट अ गुड आई थिंक प्रैक्टिस सो राद

play17:34

देन दिस वी कैन यूज एफ गेटस फंक्शन दैट वी

play17:37

विल डिस्कस इन सेपरेट वीडियो सो आई होप यू

play17:39

आर क्लियर विद स्कैनफ गेटस द एडवांटेजेस

play17:41

एंड ड्र बैक्स एंड एवरीथिंग अबाउट दिस

play17:43

थिंग यू कैन ट्राई योर ओन राइट इन द

play17:46

नेक्स्ट वीडियो वी विल सी प्रिंट एफ एंड

play17:48

पुट

play17:49

एस टू प्रिंट अ स्ट्रिंग एंड देन वी विल

play17:53

सी अ प्रोग्राम ऑन स्ट्रिंग्स एंड आई विल

play17:56

शो यू प्रैक्टिकली ऑन माय लैपटॉप सोना

play17:59

bye-bye

Rate This

5.0 / 5 (0 votes)

Related Tags
C ProgrammingStringsInitializationRuntimeScanfGetsDrawbacksFunctionsCharacter ArrayProgramming Basics