-3

I m quite new to this Systems programing i know abt the system calls but what i dont get is how to write a program to swap characters in first occurrence in a text. Hope someone can help me really struggling

1 Answers1

-5
void main()
{
    char a[20],b;
    char *ptr;
    clrscr();
    printf("\n Please Give The STRING OF A : ");
    scanf("%s",a);
    flushall();
    printf("\n Please Give The CHARACTER TO B : ");
    scanf("%c",&b);

ptr = strchr(a, b);

if (ptr)
   printf("The character %c is at position: %d\n", b, ptr-a+1);
else
   printf("The character was not found\n");
getch();

}

DON
  • 1
  • 1