| "0123456789\nABCDEFGHIJKLMN\nabc\n" |
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
/*★ 文字列を切り出す 前田 稔 ★*/
#include <iostream>
#include <string>
char str_data[]=
{ "0123456789\n"
"ABCDEFGHIJKLMN\n"
"abc\n"
};
int main()
{
using namespace std;
string s1,s2;
int pt,pw;
for(pt=0; str_data[pt]!='\n'; pt++);
str_data[pt]= '\0';
s1= str_data;
pw= pt+1;
for(; str_data[pt]!='\n'; pt++);
str_data[pt]= '\0';
s2= str_data+pw;
cout << "1番目の文字列は: " << s1 << endl;
cout << "2番目の文字列は: " << s2 << endl;
return 0;
}
|
![]()