 Good morning and welcome to the third session. Let us now begin with the first session of the day where we deal with the strings. String handling is done in two different ways. What we will be discussing is the traditional way of handling strings so that those colleagues who use pure C programming to teach the first programming course can use this kind of material and approach very effectively. The second approach is actually the string class of C++. However, the basic handling of the string is still the way C strings are handled and therefore this discussion would be useful. We will begin with the discussion of care data type then we will proceed to discuss how strings are handled and then we will have a few programming examples. As I said, this material is prepared purely from the point of view of introducing the concept to the students. We should begin by saying that characters whether a, b, c, d, 1, 2, 3, 4, alphabets or numbers or special symbols such as plus, minus, etc. These are all encoded in the machine typically using a scheme now standardized as an ASCII scheme. There used to be different coding schemes earlier. IBM persisted with EPSEDIC code which they used heavily in all their main trade machines. However, ASCII is now a dominant encoding scheme. It uses 8-bit integers that means the value range of the codes is from 0 to 255. That means at most 256 different characters can be uniquely represented in the code. At this stage itself it might be useful for us to tell our students that there could be a requirement to represent more than 256 symbols which is true for example, for many oriental languages whether it is Indian languages, Chinese, Japanese, where the number of distinct symbols that you need to represent are much more. So, there are now possibilities you might have heard of Unicode and there are very good schemes by which such symbols can be represented. Those fonts are now available. What we discuss in this programming language course is typically what has been the standard practice in CC plus plus programming languages. Here are some examples of ASCII code. For example, a blank space is encoded as 32. These are decimal values. Internally the values are stored as binary values treated in fact as hexadecimal values by most computers. So, the blank space is denoted by code 32. The symbol plus is denoted by code 43. All capital alphabets from capital A to capital Z occupy the code number from 65 to 90. So, 65 is capital A and 90 is capital Z. The small letters follow small a for example, is represented by 97. Small Z is encoded as 122. Observe that these numbers are in increasing order and they therefore define an implicit ordering on all the symbols that are represented. So, this is called lexicographical ordering and therefore, if we sort arrays containing characters on their character code, they get sorted as per their ASCII code. So, for example, small a which is 97 will be considered smaller in value than small b considered smaller in value than small c. So, this is roughly the dictionary order that we are familiar with. There are control characters which have an ASCII code, but which are not printed. They are not visible characters. For example, a new line character or a carriage return character, a line feed character. These are special characters. They are represented by a backslash n. So, ordinarily in a single code you would write a single symbol, but backslash n actually represent a single symbol. In fact, backslash is an escape character in C C plus plus. Whatever is written after that is not interpreted as the symbol that looks like n, but as a totality called backslash n. Notice that if we had not put this backslash, this would have been treated as a character. Backslash 0 is a special symbol. Its value is actually 0. It is called null. So, the null value which is actually 0 and does not correspond to either any control character or any printable character or any special character has a unique place in C C plus plus which we shall see later. Those of you who are interested in knowing all about the ASCII table, Wikipedia has an article describing the complete table of course. I do not think the link is visible, but you can go to Wikipedia and search for ASCII code. You will find an exhaustive article there. Most textbooks also provide an ASCII table in an appendix. How do we handle the care data type? The declaration permits us to define a type called care. So, you can say for example, care p comma q comma later equal to single code c single code. These actually declare two variables p and q as care type variables. This also declares later as a care type variable with an initial value. Notice that in case of integers of floating point variables, when we declare them, we can initialize them along with the declaration. Same facility is extended to care type variables as well. Now, internally C plus plus treats care type as an integer. This could sometimes cause confusion in the minds of young students. For example, suppose I have this course segment p equal to 43, where p is declared as care. First students will say, oh, you are declaring an integer value. Now, they know that when an integer is assigned to a floating point variable, a conversion occurs. They will naturally ask whether any conversion occurs. We have to tell them no, p is actually equivalent to integer. In fact, internally it is treated as an integer. As a result, if I say c of p, it will not print the numerical value 43, but it will print the character represented by 43, which is a plus symbol. That is because 43 is the ASCII code of plus and p is declared as a character variable. What would happen if we execute this code, where we assign q equal to 1097 and then say c out q? Well, in this case, the student would again be confused because this value is larger than 255, the largest value permissible for an ASCII code. Maybe you will wonder that q will take just the least significant digits of this and take it as 97. However, it should not print the small letter a when you say c out less, less q. That is because that is not how this assignment will take place. I suppose you would have figured out what would happen since this number is larger than what can be accommodated in the location for q, which is logically equivalent to a one byte location. What will happen is the higher order, first of all this number will be converted into binary number or hexadecimal number. The higher order bits will be ignored and only the lower order bits will be kept. The lower order bits, which are retained in q sadly will not correspond to the value 97, which is visible to us. You can figure out what that value would be. Now, we come to handling a number of characters put together, which we call a string. First of all, let us discuss the string constants which appear in our programs. A string constant is nothing but a sequence of characters 0 or more enclosed in double quotes. For example, give the value of n enclosed in double quotes is a string. It is a literal string. Notice that this is the kind of string that we shall use before any input operation to advise the user what is to be done. Similarly, typical output operation might contain a message with a string constant such as value of the average is so and so. Notice also that in such messages, it is common to include a blank towards the end so that the value that succeeds this in my output statement is separated automatically from this string. Here is another string. You do not have to be crazy to work here, but it helps. Somebody has written this on my whiteboard and I agree that it generally describes the prevailing atmosphere in IIT Bomb. Now, I might have to include in the strings a character such as any control character, backslash n, backslash 0, whatever. I can do so by putting a backslash as we normally do when we insert a character or allocate a character assign a character to a care variable. For example, a nation never sleeps and I want to introduce a new line character so that when the string is output automatically the cursor will go to the next line. There are occasions when I want to introduce double quotes itself into the string. Now, that seems to be difficult because any occurrence of double quotes after the first double quotes will terminate this string. Suppose I want to say he said double quote, great double quote and smile. This will be written as he said backslash double quote, great backslash double quote, comma and smile double quote. The first and last double quote is actually the enclosing double quote for the entire string. The backslash double quote, backslash double quote will actually insert the ASCII code of double quote inside this place. These appear to be simple concepts to all of us, but I have seen students often getting confused and it is useful to give such subtle examples to illustrate the point that they need to be careful while dealing with characters. The classical representation of a string, if it is not a constant string appearing in our program, but a string which we would like to store inside some variable and process it. Now, in C plus plus using the object oriented string class, it is possible to create an object of the type string. However, in the classical C programming which of course is available in C plus plus as well, we use an array to represent strings. For example, if I say P name 20, it declares P name as an array of care type of length 20 where each element holds a care value. So, consider that we wish to put our great chess maestro's name Vishwanathan Anand and store it into string. First string is defined as care n 100, second as care n 200. The 100 number is arbitrary. This is just to ensure that the capacity of an array is always large enough to hold any long name. Now, if I want to assign Vishwanathan to the array n 1, then the characters of the string are kept in the consecutive elements. So, n 1 0 will be V, n 2 0 will be I and so on. Here is an example of what happens to the word Anand if it is assigned to n 2. So, n 2 0 is a, n 2 1 is n, etcetera and n 2 4 is d. Notice that n 1 will have larger number of characters because Vishwanathan is longer, n 2 will have 5 characters. Some other string might be 20 characters. Now, how do we understand? Because once these characters disappear inside the array, we have no way of knowing where a particular string given by us or assigned by us has ended. End of the string then becomes a real painful process. C plus plus is a very interesting convention to denote the end of the string. The null character, remember I mentioned backslash 0 as a very special character. This is used to signify the end of the string within the array. So, if at all we have to insert Anand in the string n 2, then after allocating individual characters to consecutive locations, after the location which contains d, the location following it is meant to contain a backslash 0. In short, any C plus plus function which deals with string and we tell that function that this is an array which contains a string, it automatically looks for a backslash 0 to determine the end of the string. Who inserts this additional string in the array? Well, there are two ways that a character string can get inside an array. One, we do so programmatically. That means in our program we assign values to different elements such as this. In that case, it is our responsibility to ensure that a null character is inserted at the end. C plus plus will not automatically do that. The other way is to collect a string as an input. For example, it is permissible to write C in less less n 2. Notice that ordinarily a single value bearing variable is written here. This is an exception. An array name which represents a character string or other which we want to represent a character string with can be written as is in the C in statement. This will force the C plus plus to collect the input string. The input string is not a long line or something. A string is still defined as a set of consecutive characters without a blank as far as this operation is concerned. So, it will collect the name Anand for example, and automatically insert a backslash 0 at the end. Now, this representation can be used to our advantage. We can check for a backslash 0 in a string to find where the string has ended. Here is a program to input a word and output its reverse. Very simple program. Incidentally, two or three examples which follow are created after some experience dealing with the first year fresh students, particularly those who have a difficulty in understanding that individual characters are being kept inside an array and they are being manipulated. So, here is an example where an array called name 10 is defined as a character type. We ask the number of characters in the word n, then we ask people to type a word, no space in between and we read the value of name. Now, the type word is name. It is just output. The reversal is very simple. I run a for loop, but not from 1 to n, this time from n to 1. C out less, less name i minus 1. Why is this there? Please note that the nth element of name would actually be a backslash 0. You can raise some questions to the student immediately after this. Here I have said, give the number of characters in the word n. I am assuming that what I type for input actually has n characters and therefore, the last position which is the nth position in the array because position starts from 0 would be a backslash 0. That is the assumption behind writing this loop. What if I cheat and I give n as 20, but I type in only a 5 character name. You can figure out what would happen. You will get some extremely funny things on the output because this output is outputting actually one character at a time and if it encounters a content in an array element which is not a printable character, you would get something very interesting. Let us however consider the problem of reversing a string inside the character array itself. For that we would need to know the length of a string. Here is a simple program to calculate the length of a given string. For example, I enter a string without spaces. Let us call it str1 which is the care array. Notice as I mentioned, the c in will automatically insert a backslash 0 at the end. I write a loop starting with 0, examining str1 0, str1 1, str1 2, etc. in succession while str1 i is not null. If it is null, there is no more character to look at, but if it is null, then if it is not null, I go to the next character and so on. So, i is incremented. I repeat this loop. At the end, whatever is the value of 5 is the length. Consider there are 5 characters in the given string. They would be held in str1 0, 1, 2, 3, 4, 5. No, 0, 1, 2, 3, 4. These are the 5 characters. The fifth position will actually contain a backslash 0. As a result, when i is here, i will be equal to 5 when the loop breaks and 5 indeed is the length of the string. So, I can output the length of the string here. This is also accomplished by using a function called strln or string length. It is a available function in the C C plus plus string library. In order to ensure that the library is used, we are required to include this as a compiler directive before the program includes C string. The program is very similar. I get a string str1 red in. I calculate the length by saying strln str1. This is the parameter. The string is a parameter and this will return the length. Why am I doing length minus 1? Let me explain this. The purpose is to reverse this string. So, let me write some arbitrary word. Let me say cameo. Now, I want to reverse this string. That means I want to get o, e, m, a, c. The way I will reverse it is, I have to exchange c with o and I have to exchange a with e. The center character can remain wherever it is. Now, if I calculate the length, whether I do it by program or whether I use the function, I will get the length as 5. Now, I want to actually, this is the middle value. I want to exchange only 0, 1 with 3 and 4. So, this is 0. This is first. This is 3. This is 4. What I wish to do now is to exchange 0 with 4 and 1 with 3. So, I might as well start my iteration by using this value as length minus 1. This will be equal to 4. Half of this 4 is 2 and I can make my middle point as 2 here. So, what is being done here is the length. This is not really a string length, but a variable length, which is being calculated as string length minus 1. I start with i equal to 0 and while i is less than length by 2, remember the length by 2 is expected to point to the middle value and I swap the characters. I take the ith character, put it in a temporary variable. Then I take the length minus i character, put it here and then I take length, a temp character into length minus i, exchange and reverse this string. Let us say execute this algorithm for the different input strings. Let us see what happens here. Consider this. Let us take the name Vinay. The function string length will return the value 5 and length will be assigned a value 4 because I am subtracting 1 from it. Length by 2 is thus 2. Now this loop while i is less than length by 2, i starts with 0. It will execute for i equal to 0 and 1 only because the moment i becomes 2, i is no more less than 2 length by 2 and I will come out. However, this will be suffice because for i equal to 0, I will be exchanging str 0 with str 5 and for i equal to 1, I will be exchanging str 1 with str 4 and I will get the correct result. Notice however that if the input string is a 6 character name such as nagesh, we run into problem. Here the function string length will return the value 6, length will be calculated as 5 and length by 2 is 2. Now it is not 2.5 because it is an integer division. Loop will therefore run only for i equal to 0 and i equal to 1. What it means is it will exchange the 0th and the 5th position. It will exchange characters at 1st and the 4th position but the center 2 positions will remain unchanged and this will be a wrong result. The correct thing is what is intuitively obvious to us and this is the corrected program. I calculate the length as equal to string length of str 1. This is natural and once I do that, I still run my loop to i less than length by 2. Notice that if length is 5, this will automatically result in 5 by 2 which is 2 but if length is 6, this value will be result in 3 and the loop will run correctly. Again, this or similar examples are useful to indicate the nuances to students who are handling strings or characters inside an array including the complication of having to account for a backslash 0 at the end. We can read a string directly in an array using scene but it must not contain any blank. How do we read blank characters given as input? We have a sentence to be input. How do we do that? There are two different functions which actually provide mechanism to input individual characters. One is gate cap which collects every character that we type. Of course, we must press enter at the end because that is the standard feature. In some environments such as turbo and all, you have a gate c which actually collects the character the moment you type in. That is not the standard way here. More importantly, there is a function called gate s which is actually deprecated but there is a function called gate line which is equivalent. What this does is it reads the entire line till you type return. So, all characters including blanks or any other symbols, they are all read into the array. Of course, the parameter for this function must be an array declared as a care type. So, this reads the entire string typed in as input till the backslash end. The backslash end is not read. That is the new line character or carriage return that you type. When you when you hit a carriage return, but actually backslash end gets insert. The characters are stored in a and backslash hero is automatically insert. There are many good example problems that can be constructed to test our students whether they have understood array handling or not. Here are some simple problems listed. For example, read all input characters till capital X is typed as input. Store all characters in an array and finally output ASCII code values for each character in there. A very simple program familiarizing students with the ASCII codes of different characters. Read a string in an array using in gate s function. So, you get the entire string using including blanks or whatever you have and then print a cascaded code for each character in there. Third one is read a string containing first name and last name of a person separated by one or more blanks. Separate these two and output each part. Such many examples can be constructed. Here is a program. I will skip this. It just demonstrate the use of get care. As I mentioned, it defines an array of 256 elements which can contain 255. Actually, this is not going to be a string. So, you can in fact read up to 256 characters and you can output. You are not reading a string. You are reading character by character here. So, this is the program which will say get care and you have a loop which says that if C is not equal to capital X or M care is less than and M care is less than 256, you keep on doing. What it does is collects a character and puts the ASCII value of the input character here. Why am I getting 49, 32, 50, 32, 51, etcetera and not the actual printable character corresponding to this ASCII code? Let us just go back and see the declaration carefully. Notice that C is declared as care, but A array is declared as int. It is not declared as care. Now, while character and integer types are interchangeable, as we mentioned, when I output an int variable or int array element, it will print out a number. Only when output a care variable or a care array element, then I will get the printable character corresponding to the ASCII code. Here is another version where I just use M care plus plus inside the wild thing. Use the get care function inside the wild thing. Use the condition checking inside the wild thing and there is nothing else to be done in this wild loop. These kind of tricks are used. I would personally not advocate that students should use such tricks, but because many programmers use it, our students must be taught how to read and interpret such a tricky code. So, this is a code which says while M care A M care plus plus equal to get care, just analyze this part. M care is initially 0. This post increment operator will not take place now. So, at 0th value of A, you will get a value from get care and that will get assigned to A 0. The moment this assignment is over, M care will become 1 and remain 1. Now, the value that you have just got using get care is also the value of this expression and it gets examined against not equal to capital X. This is another part of the condition. When the condition ends, suppose this condition is true, you do not want to execute anything else, but rather go back and do the same thing again. So, this is a loop in itself without anybody and it does exactly what the previous program did. There are many examples in all the books. Professor Anaday's book also contains a number of good examples. Here are two problems I have stated. I am not discussing these solutions, but you will find that these problems actually are interesting problems for students to tackle and usually people learn them very quickly. It is useful that whenever students write programs on paper, you tell them to execute those programs so they can themselves see very quickly whether any jinx is happening in the sequencing of characters, etc. just as the problem that we saw in reversing the string wrongly by making wrong assumptions. This problem is what I just mentioned. If you have name and surname given in a list, you want to separate them out. This is an exercise for that. What we wish to do is read each line in a character array, separate out the first and last names and store these into separate carrier. Again, a simple exercise. More interesting exercise has come when you want to analyze a whole lot of text. For example, a sentence containing many words, find and store each word separately. So, not just two, but one, two, three, four, five and they need not be written in this fashion. There might be multiple blanks here, many blanks here, only one blank here and so on. Notice that when I use the get line, I will get automatically all of these words exactly as they are not separated. If I were to read them in separate arrays, the input operation will get rid of all these blanks, which are called white spaces. But if I read get line, I will get the entire line. The separation will then require us to do what the input operation does, namely examine each element. As long as I get non blank character, I keep accumulating it. The moment I get first blank, I should put a backslash 0 and go to another array. Now, usually you cannot have 10, 15, 17 different arrays named differently for each word. So, you use two-dimensional array here. The rows will contain different words and the columns will contain different characters of a single word. Obviously, each word will differ in length, which does not matter because the length is anyway indicated by the terminating character backslash 0. Here is a more interesting problem. Observe that this is the problem, which we saw as part of an exam paper. A sentence contains several phrases separated by comma. Store each phrase separately and then each word within a phrase. So, see the sentence. He came comma, saw that there was no one present in the room comma, sat on a chair comma and drank water. Why would such separation be sincere? When you do any natural language processing, you are interested before analyzing the semantics of the sentence, you are interested in separating out important components of the sentence. So, the phrases that you have need to be separated out. So, you have here one phrase, he came. Second phrase, saw that there was no one present in the room. Third phrase, sat on a chair. Fourth phrase and drank water. Once you have collected these phrases, you are still interested in collecting different words out of those phrases. For example, the first phrase as one word he, second word came. The second phrase as saw that there was no one present in the room. So, anyway each word itself is a collection of characters. You will remember that we had seen a small python program, which uses the split functionality available in python. C plus plus does not have directly that functionality. You can do exactly similar thing using str, talk or string token. A token is a name given to a component of a string, which is of interest to me. Tokenization is a very standard procedure in any compiler in the phase lexical analysis. We might try to tell the students that there are easier ways of doing it, but for that they will have to wait till the object oriented programming is discussed or a scripting language such as python is discussed. But as a programming exercise, it is a very good exercise, very interesting exercise to write a conventional C plus plus program to handle this as a string, separate out the list of phrases first and within each list element of the set of list, separate out the list of words. That is the exercise, which we did the other day and that shows that you may have to write a complex program through such simple thing. With this, we come to the end of the discussion of strings. Before I start the discussion on pointers, I would like to answer some questions. Yagraja College of Engineering. Sir, actually in one of the exercises which you gave yesterday, we used the function getters in one of the string based exercises, but when I tried to compile the program, it said getters is not recognized and I changed it to get line, a variant of get line function which used two parameters. The first one is the base address of the array and the second parameter is the buffer size. Could you please speculate what could be the reason for that? Yes, very good question. You will notice that in the slide today, one of the slides today I have mentioned getters and then immediately I have mentioned get line. Getters is called a deprecated function. It is actually no more supported. Getters was the original name of the function, but it is no more supported and that is why many compilers will give an error because the library with which you link your program will not contain the getters function. Get line exactly has the same behavior and same function except as you pointed out, you may have to give two parameters. One is the string name and the other is the buffer size. The buffer size would put the maximum limit. So, get line is the correct thing. Thank you for asking this question because I think this problem would be faced otherwise by many others later. So, this brings us clarity. Thank you so much. Go to, there was another question here from D. Y. Partial College of Engineering. Sir, actually I want to ask two questions which are related to a study section. The first session is while choosing a project on what weightage we need to give for certain parameters of project idea, depth of project or their lines of code. And second question is whenever we are evaluating project in that case, how to check coding level of student that is the levels of that particular language is not being certain depth level. But as per idea it is good. So, how to evaluate between these two? I will tell you different teachers will always evaluate things differently. The parameters that you mentioned are very varied. It is true that these many parameters are observable. What we do in IIT is we use the notion of relative grading. So, if there are let us say 100 projects submitted, while these projects are evaluated by different age, we always ask them to take out what they consider as the best, whatever parameter they apply and take out what they consider as at the bottom of the performance or bottom of the value, bottom of the quality. Then the teacher like me will get in and look at all the top performing projects, look at all the bottom performing projects and then will issue a sort of direction to the TAS saying that this is the top end, but in our opinion the top end does not qualify for say 100 percent marks. It qualifies in some batch for 95, some batch for 80 and at the bottom we will say this qualifies for 35 or 40, sometimes it qualifies for 50. Using this advice they will then judge. But I will tell you it is extremely hazardous to press the judgment of the quality of the project and the quality of the work done by students only on the lines of code or only of the complexity of the algorithm that they have used. The main point in a group project is the fact that they have learned to work together, is the fact that they have worked meticulously and is the fact that they have actually produced the code which is tested, which is which works and which is well documented. These are in fact the intrinsic values for any software anywhere and that is the habit that you are trying to inculcate primarily amongst your students. Good question. Thank you so much. This is Sri Narayana Gurukulam over to you. Sir actually how we can execute other programming languages like Python or Java using code blobs? When you open code blobs it actually asks you to open a particular project and that project you can choose from multiple city of choices. First of all you can choose a graphics project, you can choose a graphics project which uses a particular backend called QT and so on. Whichever languages code blobs supports is what you can use. You cannot use something which the code block does not support. If you really want to just simply test the programs there is a there is an alternative called code pad. This is not a downloadable utility or downloadable system. It is actually a website which gives you a pad on which you type in your code. It will take your code back home somewhere, execute that code and give you the results. So, this is a very simple thing for testing simple program. Now, this supports Python for example, this of course supports cc plus plus. You can even store your programs in a directory which they themselves offer you. So, this entire thing is on internet. This is not a utility which downloads on to your computer and you test it. In fact it is because of that it is actually very fascinating and simple to use. Just open a browser. You must need internet. You must have internet of course. Open a browser, go to code pad, write your code and execute it. If you want to preserve it for later usage, you can preserve it for yourself. You have a choice of making that code public in which case a large number of other people can see it and share it. Very exciting. But as far as code blocks is concerned, the limitation will be exactly what code block currently supports. Nothing prevents people from further enhancing the scope of code blocks by providing additional compiler. Please note that code block is actually just an integrated development environment. For example, the fact that we can compile cc plus plus code is because the gcc compiler system is integrated with code block. Depending upon whatever compilers you have those many languages will be supported. Code blocks per se has nothing to do with programming language. It is a development environment. This is Sree Shankaracharya Institute. Sir, our question is what is multibike character and minimize complexity of a program using multibike character? A multibike character is nothing but an encoding scheme which is different from an ASCII code system. As I said, the ASCII code is a one byte code and there are many languages which cannot be, symbols cannot be accommodated within the values of 0 to 255. So, a multibite code in fact is a code which is either 16 bits or even longer and which can represent multiple symbols, multiple characters. The complexity of your program has nothing to do absolutely with the coding system used for character symbols because if you have a multibite code it simply means that you have a larger code or a larger 2 byte or 4 byte long code which represents a single character. It just requires more space. The programming logic does not depend upon that particular thing. Of course, the programming complexity can be said to be better in case you are otherwise attempting to do the following. You are attempting to artificially put multiple bytes in your program, store components of the symbol code into each byte and then collectively treat those bytes to represent the symbol. That is a way to eat your food like this. So, that will always be complicated and in that sense the complexity would be less. But it is much better to use a coding scheme which automatically permits larger number of bytes to be internally stored. Gandhi Institute for Technology. Please, the normalization C follows the top down approach whereas the plus number follows the bottom up approach. What is the reason sir? I do not know but I apparently know less than what you do because this is the first time I am hearing something about the top down and bottom up approach. To my knowledge, C is essentially a procedural language and C plus plus is an object oriented language. When you use object oriented language like C plus plus the obvious advantages of treating complex objects and dealing with them easily emerges. When you write programs in C, you have to write in a procedural fashion. So, I do not think we should compare these two languages per se and for that matter, I would emphasize that most of the early programming that is taught to students is always taught using the knowledge of procedural programming for which whether it is C or C plus plus it does not really matter. Good morning sir. My name is J. R. Mahanty, Jyothiranjan Mahanty. Sir, last day I also asked one question. Sir, today I will ask a simple question that is there any possibilities that we can store another character except null character at the end of the string? In fact, you can store any character that you wish. You can remove backslash 0. If you are constructing a string, you need not store backslash 0 at all. You can store any other character of your choice. However, the built in functions of C plus plus will not recognize that character at the end of the string. So, that means if you decide for example to use some funny character to represent the end of the string and use that to store all your string either in files or in the program, then you will have to write all functions and all programs to examine and do something with that string. The C plus plus standard library functions will not work. Sir, who will store the null character? Actually compiler? No, no, no. You have to store. By writing your program, compiler will not, compiler does not store characters by the way. It is the functionalities such as the input operator C in which inserts a backslash 0. If you form a string yourself within a program by assigning different characters, as I mentioned explicitly, it is your responsibility to insert a backslash 0 at the end of this string. Sir, can I use doubles slash 0 instead of using single slash 0 at the end of this string? The question being asked is, can I use doubles slash 0 instead of backslash 0 alone? This will result in an extremely funny situation. Please note that backslash is actually an escape character. Whenever backslash occurs in a string, it is not considered to be a backslash character at all. When you put backslash followed by a backslash, it actually means a backslash symbol. This 0 will become redundant and this will be treated as an ASCII 0. So, an extremely funny thing will happen. Please understand that it is not for us to arbitrarily say that we want to use this character or can we use that character. C C plus plus has decided that you will end the string with a backslash 0 character. Now, if you do not like it, do not use C plus plus. But if you want to make your own choice of a character, then you will have to write all built-in functions again, so that those built-in functions will use that character at the end of the string character. Very crudely speaking, it is like saying that many people call this a pen. Can I call it pencil? Well, you can, but nobody will understand that you are calling a pen a pencil. They will think that your nomenclature is wrong. So, I appreciate this creative idea, but these fixed notions have been decided by the designer of the programming language. You and I cannot change them unless we design our own programming language. I hope that answers your question. Sir, in C, we are using ASCII 8 bit format. In C, we are using ASCII 8 bit format. Yes. Sir, can I use 7 bit format in ASCII in C? There is nothing like 7 bit format and there is nothing like you using it. Internally, C, C plus plus will always allocate 1 byte. If you get what you, when you say you will use 7 bit format, means what? You will actually give a value between 0 to 127. That is all. Notice that 0 to 127 actually has all the symbols, which we normally need. So, there is no difference between 7 bit code and 8 bit code as far as the characters that we normally handle. Internally, however, the code used is always an 8 bit code. Sir, instead of giving a text to reverse or get the output, if that particular text is available in a file and that file will be read from that particular code, and is it possible to write that code? It means you can modify the text available in that file. Yes, you are absolutely right. In fact, you should not read too much into the example which I gave. The example was merely to tell our students different ways of processing string. So, string reversal can be accomplished by multiple ways. You need not often reverse the string in the same place. You can store the reverse string in some other place and there are different ways of doing it. You are very right. So, this was just one example and you can do it in different ways and different styles. It depends on what particular problem you are trying to solve at a given juncture. I think we will stop at this place.