Am I reading User input into Arrays correctly?
So I need to read 32-bits of user input into 2 arrays and each bit is separated by a white space. When I enter the 32bits and then press enter, the program crashes.
example:
Input 32bits: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Code:
#include "stdio.h"
#include "stdlib.h"
int main (void){
int a[32], b[32], sum[32];
printf("Enter 32 bits: ");
scanf("%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,"
"%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d", a[31], a[30], a[29], a[28],
a[27], a[26], a[25], a[24], a[23], a[22], a[21], a[20], a[19], a[18], a[17],
a[16], a[15], a[14], a[13], a[12], a[11], a[10], a[9], a[8], a[7],
a[6], a[5], a[4], a[3], a[2], a[1], a[0] );
}