我对这个系统编程很新,我知道系统调用,但我没有得到的是如何编写程序来在文本中第一次出现交换字符。希望有人可以帮助我真正挣扎
答案 0 :(得分:-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();
}