 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; }
author | sky-999 |
---|---|
permlink | novice-c-language-learning-journey-8 |
category | hive-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"} |
created | 2020-03-03 09:05:57 |
last_update | 2020-03-03 09:40:51 |
depth | 0 |
children | 3 |
last_payout | 2020-03-10 09:05:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.087 HBD |
curator_payout_value | 0.086 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,039 |
author_reputation | 108,723,769,385 |
root_title | "Novice C language learning journey(8)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,012,111 |
net_rshares | 956,378,833,698 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
anarcist69 | 0 | 6,143,983,797 | 25% | ||
anomaly | 0 | 169,924,919 | 1% | ||
sn0n | 0 | 191,748,559,269 | 100% | ||
techken | 0 | 2,251,395,990 | 10% | ||
cadawg | 0 | 404,294,022,694 | 100% | ||
franciscopr | 0 | 2,644,007,199 | 100% | ||
nin4i | 0 | 414,288,600 | 100% | ||
zuerich | 0 | 348,028,056,635 | 20% | ||
laissez-faire | 0 | 4,849,452 | 100% | ||
powermom | 0 | 65,984,060 | 100% | ||
cn-leo | 0 | 114,791,055 | 2% | ||
tomhall.leo | 0 | 498,970,028 | 100% |
Thank you for posting in the programming community. Best of luck on your journey. Upvoted.
author | cadawg |
---|---|
permlink | re-sky-999-q6po59 |
category | hive-169321 |
json_metadata | {"tags":["hive-169321"],"app":"steempeak/2020.03.1"} |
created | 2020-03-05 08:12:36 |
last_update | 2020-03-05 08:12:36 |
depth | 1 |
children | 1 |
last_payout | 2020-03-12 08:12:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 91 |
author_reputation | 100,771,927,095,688 |
root_title | "Novice C language learning journey(8)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,073,254 |
net_rshares | 14,585,466,175 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
sky-999 | 0 | 14,585,466,175 | 100% |
thank you.
author | sky-999 |
---|---|
permlink | q6rus9 |
category | hive-169321 |
json_metadata | {"app":"steemit/0.2"} |
created | 2020-03-06 12:31:03 |
last_update | 2020-03-06 12:31:03 |
depth | 2 |
children | 0 |
last_payout | 2020-03-13 12:31:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 10 |
author_reputation | 108,723,769,385 |
root_title | "Novice C language learning journey(8)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,118,372 |
net_rshares | 0 |
author | voluntary-io |
---|---|
permlink | 20200303t092104036z |
category | hive-169321 |
json_metadata | {"app":"insteem/0.1","format":"markdown","community":"insteem"} |
created | 2020-03-03 09:21:03 |
last_update | 2020-03-03 09:21:03 |
depth | 1 |
children | 0 |
last_payout | 2020-03-10 09:21:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 30 |
author_reputation | 107,079,201,102 |
root_title | "Novice C language learning journey(8)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,012,338 |
net_rshares | -11,693,261,299 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
mack-bot | 0 | -26,004,414,118 | -0.25% | ||
sky-999 | 0 | 14,311,152,819 | 100% |