编译时显示警告:找不到条目符号Rrors;默认值为0000000000400590 [英] When compiled it is showing warning:cannot find entry symbol Rrors;defaulting to 0000000000400590

查看:74
本文介绍了编译时显示警告:找不到条目符号Rrors;默认值为0000000000400590的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

while循环在这里不起作用。没有编译错误,并且开始时也开始执行print语句。没有while循环的代码可以正常工作。代码是在字符串中打印出最重复的字母,并且重复的次数

the while loop is not working here.there is no compilation error and the print statement is also getting executed in the beggining.the code works fine without the while loop.the code is to print the most repeating letter in a string and the number of times it is repeated

#include <stdio.h>
#include <string.h>

int main(void)
{
    int t;
    int tempC;
    scanf("%d",&t);
    while ( (tempC = getchar()) != '\n' && tempC != EOF );
    while(t--)
   {
      char c[100];
      char r='z';
      int i,j=0,count,a,k,amx;
      gets(c);
      k=strlen(c);
      for(i=0,amx=1;i<k;i++)
      {
         if(c[i]!=0)
         {
            for(j=0,count=1;j<k;j++)
            {
               if(c[i]==c[j])
               {
                  if(i!=j)
                  {
                     count++;
                     c[j]=0;
                  }
                  a=count;
                  if(a>amx||(a==amx&&(c[i]<r)))
                  {
                     amx=a;
                     r=c[i];
                  } 
               }
            }
         }

      }
      printf("%d %c\n",amx,r);
   }

}


推荐答案

执行以下行后,

scanf("%d",&t);

换行符仍保留在输入流中。下一次对 gets 的调用最终只会读取换行符。

the newline character is still left in the input stream. The next call to gets ends up reading just the newline.

您需要添加代码以忽略其余内容读取 t 之后的行。

You need to add code to ignore the rest of the line after readning t.

scanf("%d",&t);

// Ignore the rest of the line from the input stream.
char c;
while ( (c = getchar()) != '\n' && c != EOF);

此外,不要使用 gets

进一步阅读:为什么gets函数如此危险以至不应该使用它?

Further reading: Why is the gets function so dangerous that it should not be used?.

使用 fgets

这篇关于编译时显示警告:找不到条目符号Rrors;默认值为0000000000400590的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆