employer cover photo
employer logo

Question d’entretien chez Avigilon

A long binary bit string is stored in a char array (size 128), write a function, given the char array and a number N, return a char array that has the original binary bits shifted by N bits.

Réponse à la question d'entretien

Utilisateur anonyme

28 sept. 2016

void shiftArray(char input[], int N){ int i; char* sample = malloc(sizeof(input) - N); for ( i = 0; i < sizeof(sample); i++ ){ sample[i] = input[N + i]; } memset(input, sizeof(input), 0); for(i = 0; i < sizeof(sample); i++){ input[N + i] = sample[i]; } free(sample); return; }

1