int main(){
int n,i=0,c1,c2;
char a[1000];
scanf("%d",&n);
while(n!=0)
{
a[i]=n%2;
printf("%d",a[i]); // This prints Values Correctly
n=n/2;
i++;
}
a[i]='\0';
for(i=0;a[i]!='\0';i++)
printf("%d",a[i]); //This prints only the first element of the array
}
ここでは何が欠けていますか?私がループ中にそれを印刷しようとすると動作しますが、なぜ文字配列の値をループして出力できないのですか?cの文字配列から整数を出力
'a [i]!= '\ 0''は' a [i]!= 0'です – BLUEPIXY
どうすれば避けられますか?私はstrlen(a)関数を使用することはできません、それはジャンクの値を与えます – Khacho
カウントビット(後で 'int countBit = i;') 'i
BLUEPIXY