ポインタを使用した文字反転処理
Posted: 2011年10月27日(木) 19:07
#include <stdio.h>
#include <string.h>
#define MAX_WARD 256
void main(void)
{
//===変数宣言===
char aDataIn[MAX_WARD]; //反転前文字列入力先
char aDataOut[MAX_WARD]; //反転後文字列格納先
char *pDataIn, *pDataOut; //反転前・後配列操作用ポインタ
int nStrlength; //入力文字数
int nLoopCntWord; //反転処理ループ用
printf("何か文字を入力してください(255文字以内)>");
scanf("%s", &aDataIn);
nStrlength = (int)strlen(aDataIn);
printf("\マークn文字数は「%d」文字です。\n", nStrlength);
//===文字列の反転処理===
pDataIn = ■■■■■■; //aDataIn の最終文字位置
pDataOut = ■■■■■■; //aDataOutの先頭
for( nLoopCntWord = 0; nLoopCntWord < ■■■■; nLoopCntWord ++)
{
■■■■■■ = *pDataIn;
pDataIn ■■;
pDataOut ■■;
}
■■■■■■ = ■■; //ここを入力せずに実行すると…
printf("*** 反転処理完了 ***\n");
printf("入力した文字列:%s\n", aDataIn);
printf("反転した文字列:%s\n", aDataOut);
rewind(stdin);
getchar();
}
ポインタを使用して入力された文字を反転する処理をしたいのですが黒い部分がよくわかりません。
#include <string.h>
#define MAX_WARD 256
void main(void)
{
//===変数宣言===
char aDataIn[MAX_WARD]; //反転前文字列入力先
char aDataOut[MAX_WARD]; //反転後文字列格納先
char *pDataIn, *pDataOut; //反転前・後配列操作用ポインタ
int nStrlength; //入力文字数
int nLoopCntWord; //反転処理ループ用
printf("何か文字を入力してください(255文字以内)>");
scanf("%s", &aDataIn);
nStrlength = (int)strlen(aDataIn);
printf("\マークn文字数は「%d」文字です。\n", nStrlength);
//===文字列の反転処理===
pDataIn = ■■■■■■; //aDataIn の最終文字位置
pDataOut = ■■■■■■; //aDataOutの先頭
for( nLoopCntWord = 0; nLoopCntWord < ■■■■; nLoopCntWord ++)
{
■■■■■■ = *pDataIn;
pDataIn ■■;
pDataOut ■■;
}
■■■■■■ = ■■; //ここを入力せずに実行すると…
printf("*** 反転処理完了 ***\n");
printf("入力した文字列:%s\n", aDataIn);
printf("反転した文字列:%s\n", aDataOut);
rewind(stdin);
getchar();
}
ポインタを使用して入力された文字を反転する処理をしたいのですが黒い部分がよくわかりません。