How recursive bubble sort work

                                              Recursive Bubble Sort Base Case: If array size is 1, return. Do One Pass of normal Bubble Sort. This pass fixes last element of current subarray. Recur for all elements except last of current subarray. Example: Index=     0 1  2 3 4 5 6 7   100                          90 80 70 60 50 40 30  Array []= Suppose we want to sort the above in the increasing order by the recursive bubble sort. Make a get grater which will return the grater of the array. Compare the first and last element of the array if the first is greater than last the swap with each other. And again call the sort function and decrement the array size by 1; 1) 30                     90 80 70 60 50 40 100    ...

File Handling


Filea file represent a sequence of byte on the disk where a group of related data is stored. File is created for permanent storage of data. It is ready made structure. In C, we use a structure pointer of the file type to declare a file. C programming language provides number of functions to perform basic file operations. Few of them are as under: 
Function
Description
fopen()
Create a new file or open an existing file
fclose()
Closes a file
getc()
Reads a character from a file
putc()
Writes a character to a file
fscanf()
Reads a set of data from a file
fprintf()
Writes a set of date to the file
getw()
Reads an integer from a file
Opening Files – fopen() function is used to create a new file or open an existing file, this call will initialize an object of the type FILE, which contains all the information necessary to control the stream.
Following is the prototype of this function call

FILE *fopen ( const char *filename, const char *mode );

Here, filename is string literal, which you will use to name your file and access mode can be many types such as r, w, a, as open an existing text file for reading purpose, opens a text file for writing, opens a text file for writing in appending mode respectively.
Writing to a file - The function fputc() writes the character value of the argument c to the output stream referenced by fp. It returns the written character written on success otherwise EOF if there is an error. Following is simplest function to write individual character to a stream.
int fputc ( int c, FILE *fp)

Reading from a file - The fgetc() function reads a character from the input file referenced by fp. The return value is the character read, or in case of any error it returns EOF. Following is simplest function to read a single character from a file.
int fgetc (FILE *fp) 

Comments

Popular posts from this blog

simple calculator apps project in android studio

Arrays in C Programming Language

Pointers in C