C# Code to Read File Line by Line
C Language Introduction
C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system. The main features of the C linguistic communication include low-level memory access, a simple set of keywords, and a clean way, these features make C language suitable for system programmings like an operating organization or compiler development.
Many later languages have borrowed syntax/features directly or indirectly from the C language. Like syntax of Coffee, PHP, JavaScript, and many other languages are mainly based on the C linguistic communication. C++ is nearly a superset of C linguistic communication (Few programs may compile in C, just not in C++).
First with C programming:
- Structure of a C plan
Later on the above give-and-take, we tin can formally appraise the construction of a C programme. By structure, information technology is meant that any program can be written in this structure only. Writing a C plan in any other structure volition hence lead to a Compilation Error.
The structure of a C program is as follows:
- The components of the above structure are:
- Header Files Inclusion: The starting time and foremost component is the inclusion of the Header files in a C programme.
A header file is a file with extension .h which contains C function declarations and macro definitions to be shared betwixt several source files.
Some of C Header files:- stddef.h – Defines several useful types and macros.
- stdint.h – Defines exact width integer types.
- stdio.h – Defines core input and output functions
- stdlib.h – Defines numeric conversion functions, pseudo-random network generator, retention allocation
- string.h – Defines string handling functions
- math.h – Defines common mathematical functions
- Main Method Declaration: The next part of a C program is to declare the primary() part. The syntax to declare the main function is:
Syntax to Declare the principal method:
- Header Files Inclusion: The starting time and foremost component is the inclusion of the Header files in a C programme.
int chief() {} - Variable Declaration: The next part of whatever C program is the variable declaration. It refers to the variables that are to be used in the function. Please notation that in the C programme, no variable can be used without beingness declared. Also in a C program, the variables are to be alleged before any performance in the function.
Example:
int chief() { int a; . . - Torso: The body of a office in the C program, refers to the operations that are performed in the functions. Information technology can exist anything like manipulations, searching, sorting, printing, etc.
Example:
int primary() { int a; printf("%d", a); . . - Return Statement: The terminal role of any C program is the return argument. The render argument refers to the returning of the values from a function. This render statement and return value depend upon the return type of the function. For example, if the return type is void, then there will be no return argument. In whatever other instance, there will exist a return argument and the return value will be of the type of the specified return type.
Example:
int primary() { int a; printf("%d", a); render 0; } - Writing first programme:
Following is first program in C
C
#include <stdio.h>
int main( void )
{
printf ( "GeeksQuiz" );
return 0;
}
- Let us analyze the program line by line.
Line 1: [ #include <stdio.h> ] In a C programme, all lines that start with # are candy past a preprocessor which is a program invoked past the compiler. In a very basic term, the preprocessor takes a C programme and produces another C program. The produced programme has no lines starting with #, all such lines are processed by the preprocessor. In the above instance, the preprocessor copies the preprocessed lawmaking of stdio.h to our file. The .h files are chosen header files in C. These header files by and large contain declarations of functions. We demand stdio.h for the part printf() used in the program.
Line 2 [ int main(void) ] There must be a starting point from where execution of compiled C programme begins. In C, the execution typically begins with the beginning line of main(). The void written in brackets indicates that the master doesn't accept any parameter (Come across this for more than details). main() can be written to take parameters likewise. We volition be covering that in future posts.
The int was written before chief indicates return type of main(). The value returned by master indicates the status of program termination. Encounter this post for more details on the return type.
Line 3 and 6: [ { and } ] In C linguistic communication, a pair of curly brackets ascertain scope and are mainly used in functions and control statements similar if, else, loops. All functions must kickoff and end with curly brackets.
Line four [ printf("GeeksQuiz"); ] printf() is a standard library function to print something on standard output. The semicolon at the end of printf indicates line termination. In C, a semicolon is always used to bespeak end of a statement.
Line 5 [ render 0; ] The return statement returns the value from master(). The returned value may exist used past an operating organisation to know the termination condition of your program. The value 0 typically means successful termination. - How to execute the higher up program:
In order to execute the above program, we need to have a compiler to compile and run our programs. There are certain online compilers like https://ide.geeksforgeeks.org/, http://ideone.com/, or http://codepad.org/ that tin can be used to starting time C without installing a compiler.Windows: There are many compilers available freely for the compilation of C programs similar Code Blocks and Dev-CPP. Nosotros strongly recommend Code Blocks.
Linux: For Linux, gcc comes arranged with Linux, Code Blocks can also be used with Linux.
Please write comments if you lot find annihilation wrong, or y'all want to share more than information about the topic discussed above
williamstruessen40.blogspot.com
Source: https://www.geeksforgeeks.org/c-language-set-1-introduction/
Post a Comment for "C# Code to Read File Line by Line"