【问题标题】:Is this the right statement for string comparison of two strings? [closed]这是对两个字符串进行字符串比较的正确语句吗? [关闭]
【发布时间】:2014-04-05 13:54:08
【问题描述】:
if(strcmp(p[pas].origin,"West")&&strcmp(p[pas].destination,"East")==0)
      {
       cost[pas]=5.62+5.62;
      }

这是两个输入字符串的正确代码吗?还是程序运行后出现问题但我无法获取返回值

【问题讨论】:

  • 此问题中的信息不足,我们无法为您提供帮助。直到你解释你在问什么-1。请阅读stackoverflow.com/help/mcve

标签: c strcmp


【解决方案1】:

没跑但是应该是这样的

if((strcmp(p[pas].origin,"West")==0) && (strcmp(p[pas].destination,"East")==0)
      {
       cost[pas]=5.62+5.62;
      }

【讨论】:

  • 谢谢!我让它工作并返回了正确的值
猜你喜欢
  • 1970-01-01
  • 2014-03-03
  • 1970-01-01
  • 1970-01-01
  • 2015-05-28
  • 2015-07-09
  • 1970-01-01
  • 2016-07-17
  • 1970-01-01
相关资源
最近更新 更多