unsigned long の値が例えば'aufx'が入っていたとして
その値を元にC Stringsの"aufx" もしくは NSString の @"aufx"を作りたいのですがどのようにしたらよいでしょう。
目的はNSDictionary の key にしたいのですが
//includeされています
//typedef unsigned long FourCharCode;
//typedef FourCharCode OSType;
OSType osType;
osType = kAudioUnitType_Effect; //'aufx' 61756678
char no1;
char no2;
char no3;
char no4;
char osTypeStrings[5];
no1 = (osType>>24)|(osType<<8);
no2 = (osType>>16)|(osType<<16);
no3 = (osType>>8)|(osType<<24);
no4 = osType;
osTypeStrings[0] = no1;//'a'
osTypeStrings[1] = no2;//'u'
osTypeStrings[2] = no3;//'f'
osTypeStrings[3] = no4;//'x'
osTypeStrings[4] = '?0';
のようにしてもうまくいかず
いろいろ試したのですがうまくいかないのですが
どのようにすればベストですか?
もっと簡潔な方法もありますか?
解る方、すみませんがよろしくお願いします。
No.2
- 回答日時:
全然ベストではないですが…
union X {
unsigned long x;
char c[4];
};
unsigned long x=0x61756678;
char s[5]=" ";
union X wk;
wk.x = x;
s[0]=wk.c[3];
s[1]=wk.c[2];
s[2]=wk.c[1];
s[3]=wk.c[0];
}
上記はインテル系でモトローラ系だと逆順(wk.cの添字が0~3)になります。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・人生のプチ美学を教えてください!!
- ・10秒目をつむったら…
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・【大喜利】【投稿~9/18】 おとぎ話『桃太郎』の知られざるエピソード
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
C#からC言語で作成したDLLに文...
-
-'0'の意味について
-
fgetsなどのときのstdinのバッ...
-
入力された文字列から整数だけ...
-
文字列から空白を取り除きたい...
-
プログラムの関数化
-
Cで部分配列
-
RGB→YUV変換のプログラム
-
データの取得をしたいのですが…
-
プログラミング(関数reverseを...
-
ftoa の作り方
-
'const char *' 型は 'char *' ...
-
int型変数をchar型変数に格納す...
-
C言語の式を教えて頂きたいの...
-
c++ 文字列を入力して、一文字...
-
const unsigned char *Ptn
-
charからLPTSTRへの変換方法
-
main の引数には const 付けた方が
-
間接操作のレベルとは
-
char型からのバイト数取得
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
fgetsなどのときのstdinのバッ...
-
CStringをwchar_tに変換したい
-
charでの計算?
-
文字列から空白を取り除きたい...
-
charからLPTSTRへの変換方法
-
'const char *' 型は 'char *' ...
-
テキストデータをそのままバイ...
-
配列をnビットシフトする
-
半角カナ→16進
-
double型の値をchar配列に変換...
-
sprintfに同じ変数は使えるか
-
ファイル名である文字列からbas...
-
ネットワークにつながっている...
-
ftoa の作り方
-
間接操作のレベルとは
-
型変換
-
C言語です
-
C言語のfor文です。 繰り返しの...
-
Win32APIでのエディットボック...
-
【C言語】文字型と整数型の違い
おすすめ情報