给定一个字符串Opentext print Open1ex2,即用字母t替换字符串中的t

时间:2017-10-09 15:12:15

标签: c

#include<stdio.h>
void main()
{
  char str[]="OpenText";
  int i=0,strlen,count=0;
  while(str[i]!='\0')
    i++;
  strlen=i;

  for(i=0;i<strlen;i++)
  {
     if(str[i]=='T' || str[i]=='t')
     {
       count++;
       str[i]=count;
     }
  }
  printf("%s",str);
}

我得到了输出:Openex

我没有得到所需的输出,请帮帮我。

我想得到Open1ex2作为输出,即给定一个字符串Opentext我想得到Open1ex2作为输出,即用t的计数替换字符串中的t

1 个答案:

答案 0 :(得分:0)

问题是当您将计数分配给Str [i]时,您不是将整数转换为字符。只需在计数中加上'0'即可将整数转换为字符。

Schema::table('books', function (Blueprint $table) {
    $table->unsignedInteger("reference_id")->after('access');
    $table->string("reference_type")->after('reference_id');
    $table->index(["reference_id", "reference_type"]);
});

干杯!!