Tag Archives: tab by \t

C program to replace tab by \t, backspace by \b and \ by \\

#include<stdio.h> #include<conio.h> main() {     int i,n; char a[100]; printf(“\nEnter string\n” ); for(i=0;( ( n=(int)getche() )!=13);i++) { if(n==8){  a[i]=’\\’,a[++i]=’b’;} else if(n==9){ a[i]=’\\’,a[++i]=’t’;} else if(n==92) {a[i]=’\\’,a[++i]=’\\’;} else { a[i]=char(n);} } a[i]=”; printf(“\n\n”); printf(“%s”,a); getch(); } Advertisements