Escape Sequence in C Programing By Umair

0
147
Escape Sequence in C Programing By Umair

In The Name of Al-Mighty ALLAH The All-Forgiving and All-Mercifull…

Asalam u alikum …!!!

Admin Umair Here , From Security Training ..!!

So , guys in my previous tutorial i explained what are libraries , and what is printf and what it does etc..

today i am going to explain what is a escape sequence ..!!

well , about that ..!!

when we need to give space or change new line for our output , we use escape sequence …!!

there are lots of escape sequence , i will show you only 2 of them , i.e important ..!!!

But first , let’s create our program here then in turbo c ..!!

 #include<stdio.h>
 #include<conio.h>
 void main(void){
 clrscr();
 printf("Hello world , this is Umair Ali ^_^ ");
 getch();
 }

Oka , when you run this code in a compiler it will show you this msg , but what if you want to write more than
one msg in output ?? , well for that you can use a escape sequence ” \n ” , black slash “n” ..!!

but first let’s run this program ..!!!

as you can see , when we run this code and the output we get doesn’t have any space ..!!!
neither a new line …

so this is where a escape sequence comes ..

let’s 1st check , blackslah n i.e “\n”…

 #include<stdio.h>
 #include<conio.h>
 void main(void){
 clrscr();
 printf("Hello world , this is Umair Ali ^_^ ");
 printf("\nI am Nothing without my ALLAH");
 getch();
 }

Now the output’s sec line in on another line .. !! anyways what I want to change another line ??
well , we can do it via double backslash “n ” i.e “\n\n”

Demo time ..

so i can put any amount of backslash “n ” ..!!

NOw we can do this with only one printf as well 😀 let’s see how ..!! , i will omit the sec printf ..

did you see ? , so the codes would be like :

 #include<stdio.h>
 #include<conio.h>
 void main(void){
 clrscr();
 printf("Hello world , this is Umair Ali ^_^\n\n\ni am nothing without my ALLAH");
 getch();
 }

just to make our code a little bit of short ..!! anyways …

i hope u get the point thought -_- …

let’s move to sec escape sequence , i.e backslah t , “\t” ..

Now this escape sequence , will give a space in your out put …

Demo time .. :D.
i hope you saw the output … and notice that there was a space ..

so the codes would be like …:

 #include<stdio.h>
 #include<conio.h>
 void main(void){
 clrscr();
 printf("Hello world , this is Umair Ali ^_^\t\t\tI am Nothing without my ALLAH");
 getch();
 }

~Try it out from here , practice makes man perfect 😀 😀 😀 ^_^ ..

 

Hope you got this tutorial in your heads …

i hope this would help …!!!

ALLAH HAFIZ …

ALLAH IS Great

./logout

LEAVE A REPLY

Please enter your comment!
Please enter your name here