摘要: #include<iostream>#include<string>using namespace std; const int PROFIX=2;char *newstr(char *str,char *seg,const int len){ int i; for(i=0;i<len;++i) str[i]='A'+rand()%26; str[i+1]='\0'; return strcat(str,seg); //该函数调用后seg指向新的字符数组的尾部,str指向字符数组的头部 //例如seg指向'abc'的 阅读全文
posted @ 2013-03-21 16:41 开心成长 阅读(1708) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<ctime>using namespace std;const int LEN_NAME=10;char *rand_str(char *str,const int len){ int i; for(i=0;i<len;++i) str[i]='A'+rand()%26; str[i+1]='\0'; return str;}void main(){ srand((unsigned)time(NULL)); char name[LEN_NAME+1]; cout<<r 阅读全文
posted @ 2013-03-21 14:39 开心成长 阅读(1866) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>using namespace std;void main(){ char buffer[1024]; cout<<"请输入原始报文:"<<endl; cin.get(buffer,1024); cout<<buffer<<endl; cout.write(buffer,6);}输入:ni hao ma?则会输出:ni hao ma?ni hao 阅读全文
posted @ 2013-03-21 12:06 开心成长 阅读(418) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>using namespace std;void main(){ string seg; cout<<"请输入原始报文:"<<endl; getline(cin,seg); cout<<seg<<endl;}1、上面这段代码只能读入一行,遇到回车就执行cout,比如输入:你好,ok ok!则可输出同样结果。#include<iostream>#include<string>using namespace std; 阅读全文
posted @ 2013-03-21 11:44 开心成长 阅读(353) 评论(0) 推荐(0) 编辑