Skip to main content

Posts

File Processing File Operations In C, you can perform four major operations on the file, either text or binary: Creating a new file Opening an existing file Closing a file Reading from and writing information to a file • File Definition – File is a collection of record – Record is a collection of field – Field is a block of byte – Byte is collection of bit • Possible mode value :     Mode        Description   “ r ”  opening a file to be read.   “ w ”  creating a file to be written.   “ a ”  opening a File for data append.   “ r+ ”  opening a File for read/write.   “ w+ ”  creating file for read/write.   “ a+ ”  opening a File for read/append   “rb”    opening a File (binary) to be read.   “wb”   creating a file (binary) for write operation. • Closing a File using fcloseall():        ...
Recent posts

Struct and Union

Structure And Union A structure is a user-defined data type available in C that allows to combining data items of different kinds. Structures are used to represent a record. Defining a structure:  To define a structure, you must use the  struct  statement. The struct statement defines a new data type, with more than one member. A union is a special data type available in C that allows storing different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple purposes. Defining a Union:  To define a union, you must use the  union  statement in the same way as you did while defining a structure. The union statement defines a new data type with more than one member for your program. SOURCE : Geeksforgeeks dan ppt binus maya
Sorting And Searching • Sorting needs to speed up searching operation in a list. • Sorting type: – Ascending – Descending Sorting algorithm: 1. Internal sorting     All data to be sorted are loaded to RAM 2. External sorting     Sorting process using secondary storage. • Simple: –   Bubble sort –   Selection sort –   Insertion sort • Intermediate: –   Quick Sort –   Merge Sort I cant explain here because its too long hehe..... visit binus maya to learn more Searching • Searching is an action to retrieve information based on particular key from some saved information • Key is used to do record searching which is desired from a set of data list • Key must be unique, means there must not be any same key in the data • Example:   Student data consists of name, nim , gender, address, place and date of birth   nim ...

Pointers and arrays

C Pointers and Arrays • Pointer is a variable that store the address of another variable • Syntax :   < type> * ptr_name; • Two operators mostly used in pointer : * (content of) and & (address of) • Example: Initialize an integer pointer into a data variable: int i, *ptr; ptr = &i; To assign a new value to the variable pointed by the pointer: *ptr = 5;  / * means i=5 */ #include<stdio.h>     int main() {    int arr[5] = { 1, 2, 3, 4, 5 };    int *ptr = arr;        printf ( "%p\n" , ptr);    return 0; } In this program, we have a pointer ptr that points to the 0 th element of the array. Similarly, we can also declare a pointer that can point to whole array instead of only one element of the array. This pointer is useful when talking about multidimensional arrays. int (*ptr)[10]; Here ptr is pointer that can point...

Function and Recursion

Function A function is a group of statements that together perform a task. Every C program has at least one function, which is main() , and all the most trivial programs can define additional functions. You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but logically the division is such that each function performs a specific task. A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function. The C standard library provides numerous built-in functions that your program can call. For example, strcat() to concatenate two strings, memcpy() to copy one memory location to another location, and many more functions. A function can also be referred as a method or a sub-routine or a procedure, etc. The general form of a function definition in C programming language is as follows − retur...