Show Command in C To display the contents of a file, we have the ‘type’ command in DOS and ‘cat’ to display command in unix. Program to demonstrate show command in C Save this program as ‘show.c’ and then compile and run it to get ‘show.exe’. To run this executable file, go to DOS prompt […]
Continue readingCommand Line Arguments in C Parameters and Arguments: Parameters are variables which are useful to receive data from outside into a function.The data or values passed to the function are called arguments. There are 4 ways of declaring the main() function – Command Line Arguments in C main() without any parameters We can write main() […]
Continue readingRandom accessing of file The data is stored in the form of several records in a binary files. Suppose we want to access te 4th record, then we should read from the first record till the third record. When the third record is read from the file, the file pointer reaches the end of the […]
Continue readingBinary Files in C Binary files are useful to store different types of data. For example, we have details of a bank customer like account number,name of the customer and balance amount in the account. These different types of data can be stored into a structure and then written into a binary file. The next […]
Continue readingFiles with strings To store a string into a file, we can use fputs() function. Similarly to read a string from a file we can use fgets() function. Both functions are defined in <stdio.h>. Program to store data in the form of strings into a text file. Output: In above program, we accept a string the keyboard as: We […]
Continue readingFiles with characters putc(): This function is useful to write a single character into a file. To store a character into a file shown by the file pointer ‘fp’, we can write: getc(): This function is useful to read a single character from a file. To read a character from the file represented by the […]
Continue readingFiles in C Organized collection of data is called a ‘file’. A file represents data which is arranged in a specific format and stored on a scecondary storage media like hard disk or CD. Opening a file in C We should use fopen() function to open a file. This function accepts ‘filename’ and ‘open mode’ in which […]
Continue readingUnion in C Unions are similar to structures in that they also store different types of elements. We can store different types of elements and store them in a union. Union is declared using the keyword ‘union’. Structure member operator (.) or structure pointer member (->) to refer structure elements. The same operator can be […]
Continue readingNested Structures Its possible to write one structure inside another structure. Such structures are called ‘nested structures‘. This can be achieved by declaring one structure variable inside another structure as an element. Suppose, we want to use this structure to store employee date of birth also, it can be represented as another structure To include […]
Continue readingArray of Pointers to Structures We can use array of structure pointers to print electricity bills for a group of customers. To declare array of structure pointers, we can write: Here, a total number of 50 pointers are declared which can be represented as: p[0], p[1]…. p[49]. If we want to allocate dynamic memory fpr […]
Continue reading