 �江 messages longer when when when when when when when when గాడిికోస్న్ికిలి న్బ్విరిన్నంవట్లి ఖాఖ్వినండిన్న్లా. . songs to your దిిక్నిట్నెనూతు నినిక్లి నికిట్ధితెతు బ్విన్న్లె .  stimulate  सी चादलन्चप्रीझा  सी चीहट़ी करो कूई बास्ठाच्स। श्त्ट्ङीं क्य factorial । tactical । । underground । ।.. । । । ज़ोअ वो जी धेंप करे हैं च्छॉँभो, गो आआडि़्तिप करocide. च्ल्ट खब से टिख उसब्रों़्स,拜拜 manon voy. आज्च estou deshi fazar kahending. ती ज़ांगी खुध है थी यम मेंच मश्norm मैंगउया। Wangya rescued hispp почaro, भीक शाए। तेंसा कहता यह वो जे किछा। We will clarify the following reference. నా కిగైట్ల్ల్కోచి. ఍ర్ట్ట్ల్ల్, కా దికాటుత్విండివినాచూ. అనఘిరడ్రాప్ప్స్డివిల్నాసర్టి. విమెల్ల్లు , మర్టిండి. మర్పికి వా� बार विस्गासो बाद़ी मैं से अगर आप मैं प्शूट्एँ. तो मुझ्व कहँडान्सें क्यदादिगा होष्ट्ले कमपोन है अच्टी of a रोड रोल तो लगाँँँगते वो शाच्टी बाटी करम्म्ही को रवाई अच्टी औरमात बँनारकार बअसम सबस्तुँराब्वा कोल ॐ। ौ ड़ौ ौ ॖौ ॎ Brock Taylor copyright is ौ । ॔ ॔ तट कि पवाए था वेस्टःा। कर लगन वि तिमर्आस Rama-asura- बग्यःई स्थ� manya c кар causa. तट फ्नजिम की लेट ना और विस्खर जी बगयी श� light splitara- विया की लेट विस्� hed剖ाँ को लेट विसच 립ॉत न ऋन था फिण. द़म् town from the student variable consequently I can now perform all operations that I perform programically on these individual components notice that s-.own is a character string effectively a character string show his rules hostel is an integer number so s-.hostel is an integer number is s integer? is it character? is a floating point? it is neither of thatóns is a composition of the three-component that we saw again to go back these are their thrwy components of any variable defined to be of type sttudent info And the beauty is that you are effectively defining a new type which is not provided by the programming language Programming language permits in-float, care, whatever, whatever string but you are defining a new type making CC++ aware that this is now a new type name that I'm giving And therefore hereafter if i define a variable of this type then Automatically every variable which is so defined with there a three components which are listed under that structure And i can do with individual component exactly the same thing thats i could do with the corresponding variables of the type in my Program The way in which we exist or refer to these components is always to say a make variable named .component ॐ जो एक तो पास्वाँँ वाँ ुपती्ने वाइडी क्या. वाँँँँँँँँँँँँँँँँँँ वाँिज़ावाँँँँँँँँँँँ. एक और अज बहीं से लगा टुरी जेगा चोडगमार्सू करते परमेपंगा, भी नblocking ताईईगवार प्रहींग कम आच्बार कि च़्ूँग क्यवार बाईगा कवार प्रहींग कर्ईक्छण तीवाब्त, दीवार्षकषमाज को तर ज्फद्वार प्रहींग, तीवार प्रहींग कर्ईक्छण तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो तो �  Earnest of the things in our program. कोई पहली ुरी आब आठी आर लोग आई गोभाव। ॑आद व्रउव माझे थे, the structure definitions are incorporated and understood by the compiler when the compiler is looking at either the main program or the function. आद is how the compiler will understand that when I say student info I mean that ST is a variable of the type student info which means ST also has 3 components. And all that I am doing here is I am using a printf segment. Please note also you see out for individual components. This printf is to mention to you that if you want a formatted output each particular value being printed in certain number of columns. You remember that we discussed this pretty printing months and I requested you that you should look up the printf statement and the formatting features. They are available in any standard textbook. In this particular case I am saying printf the first value is to be printed as a string in 6 characters. The second value is to be printed as a string in 8 characters and the last value is to be printed in 4 digits. Please remember that ST dot roll and ST dot name are individually character arrays of 9 and 31 characters respectively. Because when you declare a character array to store a string you need an extra character position at the end to store backslash null that is 0. So is this understood very clearly? Now you can see that while dealing with let us say a record of a student which is very long and which contains many attributes. It may contain date of birth, it may contain address, it may contain father's name, mother's name whatever whatever. You can actually have maybe 10, 15, 20 attributes describing a student. Now ordinarily we had seen earlier how we could create independent arrays to store every attribute and we could have one array containing roll numbers and the only connection between roll number and the other attributes would be through an index. So you said the roll number is let us say 27th roll number in that array. Then 27th element of the names array will contain that student's name, 27th element of hostel number will contain that student's hostel number etc. Suppose if there is any goof up and some array gets disturbed because these arrays can be handled independently then you could have a very funny situation where some roll number is big to some other hostel, to some other room, to some other name. To avoid that it would be nice if you would combine all the information about an entity called student, define it as a part of the structure and within that structure you can have individual elements which refer to a particular entity. So this roll number, that roll number's name, that roll number's hostel, that roll number's room number, that roll number's marks, that roll number's address, whatever whatever. From the point of your project there is an additional information that you might want to include in such a structure. What would be that information? You remember you are going to collect fingerprints of that student. Now that fingerprint cannot be stored inside a structure like this very easily. Obviously the fingerprints will be stored in separate files. But if you have decided intelligently on naming those files, then you can store the base name of any such file for fingerprints as a part of that student's information. So if one student has a file name associated with it, then you can extend the structure definition, can have roll number, name, hostel number, room number, whatever whatever other information and fingerprint file name as a character name. The actual file may be somewhere else, it doesn't matter. It may be in some big directory, there may be 500 such files. But once you know the name which is taught to that particular student, you will always go to that particular directory, open the specific file and you know 100% that that fingerprint belongs to that student. If there are multiple fingerprints, you can have multiple file names in this structure or alternately you can have an array of file names inside this structure. What is important to know is that structure is not limited to have simple components like integer, real, only these things. It can also have arrays as components. So this is an extremely important and flexible feature that permits you to extend the notion of collective groups of information all being given a single name through which you can extend. I am extending this concept to suggest to you that you can actually write a database kind of program. What is a database? Typically you write a whole lot of information about different entries such as student courses, their age, whatever, whatever. There is something called database schema which you define. There are database products and there are millions of lines of code that is written to have those database products. So in those databases you insert all your information. For example currently all the students information is stored in the ASC database. The product that they use is called oracle. There are multiple database products as I had once mentioned when I described the packages. Such products once you put the data into the database you can accept the data by running what is known as a query language processor to which you give queries. For example if you want to get all students of hostel 3 you might write a SQL query called select star from student database where hostel equal to 3. This becomes a simple instruction in a programming language called SQL. The SQL interpreter or SQL compiler will actually handle that query. Go to the database, extract the data and give it to you. What I am trying to show you is that it is possible for you to construct a database of a simple file and write a program which acts as an interpreter to answer simple queries. So let us see what this problem is all about. It says write a program which will read the data about students from a database file called database.txt and will answer queries of the following type given as input. So there is a file called database.txt. Resumably this file stores information in text form about a student and will limit ourselves to the information which we have seen as a part of that structure definition but as you know you can extend that structure definition. So the purpose is that the program should first read this file and read all the data in memory because you can actually have memory RAS which can contain all students data. But anytime any changes happen those changes should be reflected in the file because file remains permanently, memory vanishes. So every time the query has to be answered your program should read the entire data from that file into memory and then answer those queries and we are defining a new query language all about. What is that query language? That query language consists of a query code followed by a parameter. So here is a query code N. If I say L it means I want the name of the student and if I say 8 it means list names of HAT students. If I say R that means I want information about specific role number. The parameter is the role number. So full information about given role number. If I say H followed by 3 I want all information about H3 students. If I say X that means exit. You can see that the definition of M, R, H, X is completely artificial. I am defining it. You can define your own query language, your own symbols. Z means this, P means this, whatever one. It need not be a single character symbol. You can define a query which is more meaningful. So you see the amount of flexibility that you have you can relatively define your own queries and write programs which will answer those queries using the information which has been stored in the files first. It is almost like defining a new programming language and writing an interpreter for that language. Of course the actual programming language definition and writing an interpreter is a big time task. What I am telling you is that fundamentally and conceptually it is a very simple thing which all of you can do. And in fact I would encourage you to consider query for the project databases that you will create or project files that you create. For us database means one or more files. We know how to create files. We know how to read files. But instead of writing a specific program to answer one query I might generalize and I might include the interpretation and execution of those queries in a generalized program. So here is an example. This is a sample program to answer one query. This what is written here is called pseudo code. It is not written in any programming language. It is written in plain English. While we have not studied this way of designing algorithms this is the most popular way in which serious programming starts. You don't start writing programs but you start writing an algorithm on a step by step process in something like a pseudo language or an English like language. I presume all of you can understand what I am trying to write it here and that is the beauty in this simplicity. So what this program says this is not a program in a programming language this is a pseudo code. It says read in the database.txt then set up some variable term equal to 0 while term is equal to 0 reading the option. Option means h or x or r or whatever. If option is h perform action else if option is x that is exact then is equal to 1 n. Now this is the simple kind of query interpretation that you can write. If you have multiple options you can put an else if ladder or the switch statement. If option is h then do this if option is n do something else if option is pq or do something else and at the end you get out. Observe that I have said student info student list 100 this permits up to 100 students data to be stored here. What if I want to input data for all students attending CS 101 the only thing that I have to do is to increase this number from 100 to let us say 1000. What if I want to store the data for all students in the institute campus well let us estimate how many students are there about 7000 Assuming that the program will be used for next 4 or 5 years during which time the population may grow it would be safe to change this to say 10000. As a matter of fact we should not put explicit numbers in real programs we could say something like max student which is defined as a constant because if this number is required to define multiple arrays then by changing the constant value of max student ones and recompiling the program every array that you have defined using that value will automatically be recompiled properly but it doesn't matter. The point I am making is that as per the structure that we have defined we have seen how we define individual variables I can even define arrays where each element of the array now is of the type student info or option it is assumed that the query language that I am designing has one character code h means hostel n means name r means role x means exit etc but you can easily change it to whatever you wish to do there are some integer variables defined I am now defining a file called input stream input file stream f in this is artificial name of which I am giving fin.open.database.txt it will open the text file observe that my structure contains a value which is integer some values which are character there could be some values which are float etc but the file in which I am storing all of this is a text file why? because it is easier for me to see the text file whether it is correct it contains correct data or not etc of course I could define this file to be a binary file we shall see how binary files are handled in the next lecture I am also defining a variable called s which is student info what is the purpose the purpose is when I read one line from that file I would rather extract information about one student into a simple variable of the structure type s in different components I would also like to answer query why I am reading the file where I know what the query is so instead of first reading and then again going through all the other that I have created and finding out the query answer I might as well answer the query as I am reading the data ordinarily however this is not how you will organize you will organize your program such that you read the entire data stuff it into the arrays inside your program variables and arrays and then start looking at query one by one so you can answer multiple queries if you look at the data in the arrays rather than in the files this is a simplistic program where I have written the following way that I read the data and I also answer the query while reading the data let us see what I am doing I first read the value of l this is the number of students then I say for i equal to 0 i has the name i plus plus I read in the s dot name s dot rule done is equal to 0 while done equal to 0 give your option I read the option if the option is x done is equal to 1 that means I exit if the option is h I want to get the hostel number I read the hostel number I output the hostel number now s is equal to student list i so please note I have read the data in the student list array at any point I am going through all the information there are n students so there are n numbers in student list for every value of i I am extracting the information from that student list and passing on to the complex type structure that I have created and the variable is s so every time I do this this assignment is perfectly legal by the way I am taking a complicated group variable array some element from that array and putting it into a single variable s which is again of the same complex type once I do this assignment s not hostel, s not may, s not roll everything gets defined what was my query query was that for a given hostel number give me all the information I will simply check if s not hostel is hostel number that is the hostel number which I have desired that is the parameter for my query say hostel number is 3 for example any time out of these n students every student has s not hostel as 3 that students information will be printed and I am again using the same function print student s this answers the query this is end of y so I can go back and again give another query I can go back again give a third query when I say x when x is given you remember that done would have been said to 1 and the while loop will be back I will come out of so the point that is being made in this kind of query is that in general you should work for storing your data permanently in computer files on the desk arrays are useful to store data temporarily during which time your program is executing so that you can answer different queries but if there is any change that happens by changing the students hostel number or room number for example in a memory array is good for execution of that program but once the program execution stops the changes will disappear correspondingly you may also write another program which is called update database program what does that update database program do it will take any new information about a student and will replace the old information in the file with the new information for that there are 2 ways of doing it one you of course read all the students information from file into the memory then you keep collecting update information about different students every time you get a whole number let's say room number change or a hostel number change you make that change in the corresponding arrays and after all changes are collected you recreate that file you rewrite the entire file with the new information that is one way the second way is that if you are going to update an individual student some information about two students why do you want to read the entire information about all students why not go directly to the file to the place where that student's information is stored and update that information in place that is read the disk as if it is an array of bytes provided you know exactly which byte to update to change the whole number or which bytes to update to change the hostel number you will be able to correctly update that directly this is what we are going to discuss when we discuss random access files and binary files unfortunately this discussion has to happen in the next lecture so we have to close this but this is the direction I would like you to take while you design your file formats and so on thank you