These program codes help us to play with strings in C.
This Program code inputs a string and displays the characters until a single character.
This Program code inputs a string and displays the characters until a single character.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<string.h> | |
#include<stdio.h> | |
int main() | |
{ | |
char o[50],c,t; | |
int i,j; | |
printf("Enter the string: "); | |
gets(o); | |
printf("Enter the terminating character: "); | |
scanf("%c",&t); | |
j = strlen(o); | |
for(i=0;i<j;i++) | |
{ | |
if( o[i] == t ) | |
{ | |
break; | |
} | |
else | |
{ | |
printf("%c",o[i]); | |
} | |
} | |
getch(); | |
return(0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<string.h> | |
#include<stdio.h> | |
int main() | |
{ | |
char o[50],t; | |
printf("Enter the string: "); | |
gets(o); | |
printf("Enter the character to except: "); | |
scanf("%c",&t); | |
int i,j; | |
j = strlen(o); | |
for(i=0;i<j;i++) | |
{ | |
if(o[i] == t ) | |
{ | |
continue; | |
} | |
else | |
{ | |
printf("%c",o[i]); | |
} | |
} | |
getch(); | |
return(0); | |
} |
Comments
Post a Comment