
II-182 Programming Concepts
11.
#include <string.h>
void main()
{
char a[40]={"Software people are intelligent"};
char b[40];
clrscr();
strcpy (b,&a);
printf("%s \n %s",a,b);
getche();
}
Bug: *&a instead of &a.
strchr()Function
12.
#include <string.h>
#include <conio.h>
void main()
{
char text[30]="SINGAPUR",cha,*chp;
clrscr();
printf("\nString is:-%s",text);
printf("\nCharacter to find :");
cha=getchar();
chp=strchr(text[],cha);
if(chp!=0)
printf("Character %d found in text.",cha);
else
printf("Character %d not found in text.",cha);
}
Bug: [] is not needed in chp line and %c is to be placed in place of %d in
printf statements.
strset()Function
13.
#include <st ...