Docstoc

Dynamic File Handling

Document Sample
Dynamic File Handling Powered By Docstoc
					      DYNAMIC
File Handling in C++




    Copyright © 2010 Global IT Solutions. All Rights Reserved.
File handling of c++ is something which provides the programmer to maintain a database for the

program.




As we all know, we need something huge to store data of big programs which are made for some

organizations, company, store, etc.


Now you must be thinking how we can use the program of c++ for such big issues, which has no

fixed amount data, as its dynamic.


As we all know that we specify the filename of the file at the time of declaration of pipeline in

the hard core. So, it’s difficult to have dynamic filename creation.


For Example:


         File x;


         x.open(“filename.dat”);


Now, from the above example we can see that the filename is static; we cannot have more then

on file name if needed.


For this to be done, I will take you to some basic concepts of C++. If you remember there are

declaration formats of character in C++


For example:


   1.)     char c;

         c=’h’;



                      Copyright © 2010 Global IT Solutions. All Rights Reserved.
    2.) Char c=’h’


From the above example we can see that anything written in ‘ ‘ are the characters and they can

be stored in a char type of variable.


And we also know that anything written in “ “ is the character string and that can be stored in a

character type of array.


Hence filename written in the function open(); is in “ “ so that file name can be easily stored in a

character array.


For example:


Char ch[10]=”abcde.dat”;


File x;


x. open(ch);


Now in the above example ch represents the file name .




Now as we know that filename written in the function open() is an array, so now we can easily

manipulate the character array to get dynamic file handling using functions of character like

append(), gets(), etc.


I have developed a digital diary in which there are various modules like


    •     Phone Book

    •     Scheduler


                         Copyright © 2010 Global IT Solutions. All Rights Reserved.
   •   Calculator

   •   Conversion


Now in this digital diary one can easily get registered with the user name and password of his

own choice. After that user will have secured area in which he has its own phone book and other

modules. Similarly 100’s of users can register and all will have their own data stored in different

files with their names.




This all gets possible due to the above concept explained above.




                      Copyright © 2010 Global IT Solutions. All Rights Reserved.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:30
posted:9/12/2010
language:English
pages:4