create account

Novice C language learning journey(8) by sky-999

View this thread on: hive.blogpeakd.comecency.com
· @sky-999 · (edited)
$0.17
Novice C language learning journey(8)
![梦幻光晕蓝色背景矢量图.png](https://cdn.steemitimages.com/DQmeWGa19sY4X6wLEcCrmGeR1RAM1emGEyft1vytQcnqxVo/%E6%A2%A6%E5%B9%BB%E5%85%89%E6%99%95%E8%93%9D%E8%89%B2%E8%83%8C%E6%99%AF%E7%9F%A2%E9%87%8F%E5%9B%BE.png)
How to judge the two string that is it equal?I try run the code as follows.But it can not implement the function.Because it directly take the two string to compare.The code as follows:

       #include"stdio.h"
       #include"stdlib.h"
       main(){
       char m[5];
       if(gets(m)=="abc")
       printf("a\n");
       else
       printf("b\n");
       system("pause");
       }

So how to modify?
I create a function be used to compare.Put the every character to compare.The code as follows:

      #include <stdio.h>
      int _strcmp(char *s1, char *s2)
      {
      for (; *s1 && *s2 && *s1==*s2; ++s1,++s2) NULL;
      return *s1==*s2 ? 0 : *s1>*s2 ? 1 : -1;
      }
      int main(void){
      char m[5];
      if (_strcmp(gets(m),"abc") == 0)
        printf("a\n");
      else
        printf("b\n");
      return 0;
      }
👍  , , , , , , , , , , ,
properties (23)
authorsky-999
permlinknovice-c-language-learning-journey-8
categoryhive-169321
json_metadata{"tags":["programming","steem","softfork","oc","posh"],"image":["https://cdn.steemitimages.com/DQmeWGa19sY4X6wLEcCrmGeR1RAM1emGEyft1vytQcnqxVo/%E6%A2%A6%E5%B9%BB%E5%85%89%E6%99%95%E8%93%9D%E8%89%B2%E8%83%8C%E6%99%AF%E7%9F%A2%E9%87%8F%E5%9B%BE.png"],"app":"steemit/0.2","format":"markdown"}
created2020-03-03 09:05:57
last_update2020-03-03 09:40:51
depth0
children3
last_payout2020-03-10 09:05:57
cashout_time1969-12-31 23:59:59
total_payout_value0.087 HBD
curator_payout_value0.086 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,039
author_reputation108,723,769,385
root_title"Novice C language learning journey(8)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,012,111
net_rshares956,378,833,698
author_curate_reward""
vote details (12)
@cadawg ·
Thank you for posting in the programming community.

Best of luck on your journey. Upvoted.
👍  
properties (23)
authorcadawg
permlinkre-sky-999-q6po59
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"steempeak/2020.03.1"}
created2020-03-05 08:12:36
last_update2020-03-05 08:12:36
depth1
children1
last_payout2020-03-12 08:12:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length91
author_reputation100,771,927,095,688
root_title"Novice C language learning journey(8)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,073,254
net_rshares14,585,466,175
author_curate_reward""
vote details (1)
@sky-999 ·
thank you.
properties (22)
authorsky-999
permlinkq6rus9
categoryhive-169321
json_metadata{"app":"steemit/0.2"}
created2020-03-06 12:31:03
last_update2020-03-06 12:31:03
depth2
children0
last_payout2020-03-13 12:31:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation108,723,769,385
root_title"Novice C language learning journey(8)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,118,372
net_rshares0
@voluntary-io ·
Welcome to Steemit @sky-999 :)
👍  
👎  
properties (23)
authorvoluntary-io
permlink20200303t092104036z
categoryhive-169321
json_metadata{"app":"insteem/0.1","format":"markdown","community":"insteem"}
created2020-03-03 09:21:03
last_update2020-03-03 09:21:03
depth1
children0
last_payout2020-03-10 09:21:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length30
author_reputation107,079,201,102
root_title"Novice C language learning journey(8)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,012,338
net_rshares-11,693,261,299
author_curate_reward""
vote details (2)