$ echo -n '記号' | od -x 0000000 a8e8 e598 b78f
とすると,マルチバイト文字ごとに,バイトの連なりが逆になってしまう. そこで次のように処理する.
$ echo -n '記号' | hexdump -C 00000000 e8 a8 98 e5 8f b7
#include<iostream>
#include <string.h>
using namespace std;
void test(char * input){
cout << input << endl;
}
int main()
{
char input[5120];
strcpy(input , "これはテスト");
test(input);
return 0;
}
#include <map>
#include <vector>
#include<iostream>
using namespace std;
void setText(vector<string> &v, map <string, int> &m1,
map<string, int>::iterator & pa){
cout << "v.size = " << v.size();
pa = m1.begin();//
for(int i = 0; i < v.size(); i++){
// pa = m1.find(v[i]);
if( (pa = m1.find(v[i])) != m1.end()){
// if( (m1.find(v[i]))->second > 0){
//すでにマップにあるのなら
cout << "find" << endl;
pa->second = pa->second + 1;
// (m1.find(v[i]))->second =
( (m1.find(v[i]))->second) + 1;
//二つ目の数値を加算
}
else{// そうでないなら,データを挿入
// pa.first = v[i];
// pa.second = 1;
m1.insert(make_pair(v[i], 1));
// cout << "find " << endl;
}
}// end_for
}
int main()
{
vector<string> v;
map<string, int> m1;
map<string, int>::iterator pa;
v.push_back("加藤");
v.push_back("鈴木");
v.push_back("佐藤");
v.push_back("山田");
setText(v,m1,pa );
pa = m1.begin();
int n = (int)m1.size();
for(int i = 0; i < n; i++){
cout << pa->first << " " << pa->second << endl;
pa++;
}
return 0;
}
その2
#include <map>
#include <vector>
#include<iostream>
using namespace std;
void setText(vector<string> &v, map <string, int> & m1,
map <string, int> & m2, int z,
map<string, int>::iterator & pa,
map<string, int>::iterator & pa2 ){
cout << "v.size = " << v.size();
for(int i = 0; i < v.size(); i++){
if( (pa = m1.find(v[i])) != m1.end()){
cout << "find in ma1" << endl;
pa->second = pa->second + 1;
}
else{ // そうでないなら,データを挿入
// pa.first = v[i];
// pa.second = 1;
m1.insert(make_pair(v[i], 1));
// cout << "find " << endl;
}
// pa = m1.find(v[i]);
if( (pa2 = m2.find(v[i])) != m2.end()){
cout << "find in ma2" << endl;
pa2->second = pa2->second + 1;
// (m1.find(v[i]))->second =
( (m1.find(v[i]))->second) + 1;
//二つ目の数値を加算
}
else{ // そうでないなら,データを挿入
m2.insert(make_pair(v[i], 1));
}
}// end_for
}
int main()
{
int i = 0;
int j = 0;
vector<string> v;
map<string, int> m1,m2[2];
map<string, int>::iterator pa, pa2;
v.push_back("加藤");
v.push_back("鈴木");
v.push_back("佐藤");
v.push_back("山田");
for(i =0; i < 2; i++){
pa = m1.begin();
pa2 = m2[i].begin();
// setText(v, m1, m2, i, pa, pa2);
setText(v, m1, m2[i], i, pa, pa2);
}
int n = (int)m1.size();
pa = m1.begin();
for(i = 0; i < n; i++){
cout << pa->first << " " << pa->second << endl;
pa++;
}
cout << "next" << endl;
for(i = 0; i < 2; i++){
cout << "i = " << i << endl;
pa2 = m2[i].begin();
for(j = 0; j < n; j++){
cout << " j = " << j << endl;
cout << " " <<pa2->first << " "
<< pa2->second << endl;
pa2++;
}
}
return 0;
}
よく忘れてはまる.pa は map <string,int> ma のイテレーターとする
printf("word = %s: freq = %d\n",
(pa->first).c_str(), pa->second );
$ gcc -finput-charset=Shift_JIS hoge.c -o hoge.o
http://osdir.com/ml/gnu.mingw.user/2002/msg03869.html
"__declspec(dllimport)" and "extern __declspec(dllexport)" both imply a declaration, but that "__declspec(dllimport)" causes the linker to look for the __imp symbol in an import library, while "extern __declspec(dllexport)" declares a function that must be defined in the program's source (no __imp prefix).
設定されている環境変数を表示するには、printenvコマンドを
正確には,リンカの一に依存しないコードを生成する.
p.34