How to Create Linked List in C/C++

##Source Code #include <stdio.h> #include <stdlib.h> struct Node{ int data; struct Node *next; }; typedef struct Node *node; node createNewNode(){ node temp; temp = (node)malloc(sizeof(struct Node)); // allocate memory equal memory as the size using malloc() temp->next = NULL;// make next point to NULL (suppose this as last node) return temp; } node addNode(node head, int value){ node tmp,p; tmp = createNewNode(); tmp->data = value; if(head == NULL){ head = tmp; } else{ p = head; while(p->next !...

January 2, 2019 · 1 min · Rahul Rajput

File Handling in C (Reading a file line by line)

In this tutorial, we are working with the files in the C. File handling in any language requires Three main steps to follow Open the file in Read/Write mode. Do various operation that you want to do. Close the file. We are using fopen(file stream). There are some modes to open a file. Read mode opens file into the read mode if file not found returns -1. Write mode opens file into the write mode if the file does not present creates a new file if there is previous data it will be overwritten....

December 18, 2018 · 2 min · Rahul Rajput

Bascis of Pointers In C language

A pointer is a variable which contains the address of the variable specified. For example: int x = 100; int *data; data = &x; This variable data contains the address of the block in the memory which contains the value 100. * specifies that this is the pointer variable. & gives the address. that is the what I am doing here assigning the address of the integer variable x to the pointer variable data....

December 18, 2018 · 3 min · Rahul Rajput

Finding Length of an Array in C

Array in C an array is a collection of a variable of a fixed number of the same data type in a sequential memory. an array can be declared in various ways. one of them is given below int x[] = {200,300,522,655}; char y[] = {'x','s','r'}; int n[10],j; // first declaring the array // then assigning the value. for ( j = 0; j < 10; j++ ) { n[ j ] = j + 100; } indexing in C array starts from the 0....

December 18, 2018 · 2 min · Rahul Rajput

C/C++ program to check the Palindrome string.

Palindrome string: A string or word which are same from the start and end means word or program which look like same as original and reversed. To do that we have to first reverse the string. Check out our post on the String reverse in C/C++. To write the program of the Palindrome steps used are. Get the input from the user. convert the string to the Lower case to avoid any case sensitivity....

December 17, 2018 · 3 min · Rahul Rajput

C/C++ program to Reverse a String

String In C language string is an Array of the Char variable. to write a program of the string reverse we have to break this program into steps as always. Take input from the user. Reverse the string using the for loop print the final answer to the user. First of All, create a schema for the program. #include <stdio.h> #include <string.h> int main(int argc, char const *argv[]) { return 0; } Now write some code for the Taking input from the user....

December 17, 2018 · 2 min · Rahul Rajput

Split a string in C/C++ and Python

Splitting a string by some delimiter is a very common task in programmers day to day life. For example, we have an email address, and we want to extract email host which is part after @ in email address, example@gmail.com. After splitting this email address by “@”, there will be two strings “example”, “gmail.com”. Use case of string splitting contains, tokenizing things in compilers, extracting relevant data with Web crawlers etc....

December 11, 2018 · 1 min · Rahul Rajput