关键词搜索

源码搜索 ×
×

小程序分享:str1和str2对应的串相等, 但是a.txt和b.txt不相同。

发布2014-07-31浏览7646次

详情内容

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. char str1[100] = "ab\0cdddddddddd";
  6. cout << str1 << endl;
  7. FILE *fa = fopen("a.txt", "wb");
  8. fwrite(str1, sizeof(str1), 1, fa);
  9. fclose(fa);
  10. char str2[100] = "ab";
  11. cout << str2 << endl;
  12. FILE *fb = fopen("b.txt", "wb");
  13. fwrite(str2, sizeof(str2), 1, fb);
  14. fclose(fb);
  15. if(0 == strcmp(str1, str2))
  16. {
  17. cout << "yes" << endl;
  18. }
  19. else
  20. {
  21. cout << "no" << endl;
  22. }
  23. return 0;
  24. }

相关技术文章

最新源码

下载排行榜

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载