数组反转存储

#include<stdio.h>
#include

int main()
{
      voidantitone(char *a);
      int i;
      charch[10];
      printf("enter the string\n");
      for(i =0;i<10;i++)
      {
              scanf("%c",&ch[i]);

      }
      antitone(ch);
      for(i =0;i<10;i++)
      {
              printf("%c",ch[i]);
      }
      return0;
}

void antitone(char *a)
{
      int i =0,j=1,flag = 0,temp;
      while(i<10/2&&j<10-1)
      {
              if(flag||(a[10-j-i]!=' '))
              {
                      temp = a[10-1-i];
                      a[10-1-i] = a[i];
                      a[i] = temp;
                      flag =1;
                      i++;
              }
              else
              {
                      continue;
                      j++;
              }

      }

}
 
there're some error remaining in the codes.when i input the stringending with space ,the system can't distinguish what i enter ,andgoes into a endless loop. Butif i use the sentence of "gets" ,i must face another quetionthat  i will overstep the boundary of thearray when someone inout chars more than the length of arraydefined.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值