String will be terminated when it reaches ‘\0’ character:
int main() { printf(“Hello \0 World \n”); return 0; } |
Analyze the output of following code:
int main() { printf(“Hello World \0 \n”); printf(“Hello \0 World \n”); printf(“\0Hello World \n”); return 0; } |
Note: Strings can be processed with \0 character only. ASCII value as follows.
#include<stdio.h> int main() { printf(“\0 ascii value is : %d \n”, ‘\0’); return 0; } |
Note: In the above program, printf() function stops printing string when \0 reached.
Program to print null character(\0) on console:
int main() { printf(“\\0 ascii value is : %d \n”, ‘\0’); return 0; } |
Program to display Strings with quotations:
int main() { printf(“This is ‘C-lang’ class \n”); return 0; } Output: It is ‘C-lang’ class |
int main() { printf(“It’s a C class \n”); return 0; } Output: It’s a C class |
int main() { printf(“I am attending \”C – Online\” class \n”); return 0; } Output: I am attending “C – Online” class |
int main() { printf(“She said, \”It’s a good one\” \n”); return 0; } Output: She said, “It’s a good one” |