EmbLogic's Blog

Author Archives: Ankur Garg

Different methods of swapping 2 numbers

#include<stdio.h> void swap(int *,int *); int main() { int temp; int *t; int a=100,b=200; //Using 3 variables //1.1 temp = a; a = b; b = temp; printf(“%d %d\n”,a,b); //1.2 swap(&a,&b); printf(“%d %d\n”,a,b); //Using 2 variables //2.1 a += b; … Continue reading

Posted in Data Structures with C | Tagged , , , , | Leave a comment

Errors in “Hello World” program

#include<stdio.h> int main() { printf(“Hello World”); return 0; } /* Errors Line 1 :- *1. If u remove only preprocessor (#)->error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token *2.#nclude<stdio.h> ->  error: invalid preprocessing directive #nclude *3. #include … Continue reading

Posted in Data Structures with C | Tagged , , , , , , | Leave a comment

What is Character Driver?

A character device driver is one that transfers data directly to and from a user process. This is the most common type of device driver and there are plenty of simple examples in the source tree. Character device drivers may … Continue reading

Posted in Character Driver | Tagged , , , , | Leave a comment

ls – list command

ls – list command ================= – ls means list directory content – Prototype : ls [OPTION] … [FILE] … – Exit status It returns 0 ,on success Returns 1 in case of minor problems (eg. cannot access subdirectory) returns 2 … Continue reading

Posted in Shell Scripts | Tagged , , , , , , , , , , , | Leave a comment

CD – Change Directory Command

CD – Change Directory Command ============================= – cd means change working directory – Prototype: cd [-L | -P] [directory] cd – -If you do not give any directory to cd command, it will take you to home directory. eg. cd … Continue reading

Posted in Shell Scripts | Tagged , , , , , , | Leave a comment

Common linux virtual directories

Common Linux Virtual Directories ================================= Directory               Usage / Root                     of virtual directory. No files are placed here (normally) /bin         … Continue reading

Posted in Shell Scripts | Tagged , , , , , , , , | Leave a comment

Linux Filesystem

Linux Filesystem ================ – In windows, physical drive determines the pathname of the file. – Windows assigns a letter to each disk drive. – Each directory contains its own directory structure for accesing files stored in it. – For eg. … Continue reading

Posted in Shell Scripts | Tagged , , , , | Leave a comment

How to get help in Linux – Fedora

To get help in fedora ===================== To learn about any new command, function or utility in Fedora we can get help from it. It has 3 such commands :- i) man pages – These are manual pages . – It … Continue reading

Posted in Shell Scripts | Tagged , , , , , , , , | Leave a comment

How to change default prompt in BASH shell

To change default prompt :- ======================== – We can change default prompt by assigning the character to it. – Each character have a specific meaning. BASH Shell Prompt Characters :- Character Description \a Bell Character \d Date in format “Day … Continue reading

Posted in Shell Scripts | Tagged , , , , , , , , | Leave a comment

Command line Prompt – PS1, PS2

Command line Prompt =================== Environmental variables that controls Command line Prompt PS1 : Controls the format of default command line prompt. PS2 : Controls the format of second-tier command line prompt. PS3 : Controls the format of tertiary command line … Continue reading

Posted in Shell Scripts | Tagged , , , , , , , , | Leave a comment

Linux Run Levels

Linux Run Levels ================ Run Level    Description 0                    Halt 1                     Single-User mode 2                    Multi-user mode, usually … Continue reading

Posted in Shell Scripts | Tagged , , , , , | Leave a comment

Boot process of linux

The boot process of linux ========================= – After you turn on your Linux System, linux kernel loads into memory and runs. – Firstly, it runs the init process. – init program is usually located at /sbin/init. – init process has … Continue reading

Posted in Shell Scripts | Tagged , , , , | Leave a comment

Sockets – Basics

Sockets ======= A socket is a communication mechanism that allows client/server systems to be developed either locally,on a single machine, or across networks. – It is a communication mechanism – It allows client/server systems to developed either locally or across … Continue reading

Posted in Project 04: FTP based Client Server using Threads and Sockets | Tagged , , , , | Leave a comment

fgets – scanning string with spaces

Prototype : – #include <stdio.h> char *fgets(char *s, int size, FILE *stream); Defination :- fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s.  Reading  stops  after an … Continue reading

Posted in Data Structures with C | Tagged , , | Leave a comment

Bubble sorting using function

#include<stdio.h> //Program for Bubble Sorting int * bubblesort(int*,int); int display(int *,int); int main() { int i,j,a[100],N,temp; printf(“Enter no.of elements you want to sort:\t”); scanf(“%d”,&N);//Max. no. of elements printf(“Enter %d elements you want to sort:\n”,N); for(i=0;i<N;i++) scanf(“%d”,(a+i)); printf(“\nBefore sorting:\t”); display(a,N); //Sorting … Continue reading

Posted in Data Structures with C | Tagged , , , , , , | Leave a comment