单链表的逆转
测试is-programmer服务器地点

潜藏在代码中的Bug

yichen posted @ 2014年5月28日 22:08 in Essay , 639 阅读
  1 #include <iostream>
  2 #include <string>
  3 #include <cstring>
  4 using namespace std;
  5 
  6 int main()
  7 {
  8     string s = "hello world!";
  9     const char *str = s.c_str();
 10     char ch[100];
 11     int i = 0;
 12     while(*str != '\0')
 13     {
 14         ch[i++] = *str++;
 15     }   
 16     cout << ch << endl;
 17     return 0;
 18 } 
 
 
请将10行中的数组初始化,或者退出while循环后增加语句ch[i] = '\0' 。
另外,可以有:s + ' a' + str + "welcome" + ch 。想想string类的特征。
Avatar_small
AP 10th Maths Questi 说:
2022年9月10日 22:00

Mathematics is one of the tough subjects and also an easy subject for class 10th standard students of TM, EM, AP 10th Maths Question Paper UM and HM studying at government and private schools of the state. Department of School Education and teaching staff of various institutions have designed and suggested the Mathematics question paper with solutions for all chapters topic wide for each lesson of the course, and the AP SSC Maths Model Paper 2023 Pdf designed based on the new revised syllabus and curriculum.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter