9951 explained code solutions for 126 technologies


cSet a value to every byte of an array


#include <string.h>
memset(arr,0,sizeof(type)*length);ctrl + c
arr

Name of array

0

The value (consult ASCII table for more datails) which every byte of array will be attributed

sizeof(type)*length

Space of array in bytes


Usage example

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define len 5
int main(){
    char *arr = malloc(len*sizeof(int));
    printf("%s\n", arr);
    memset(arr,49,sizeof(char)*len);
    printf("%s", arr);
    free(arr);
    return 0;
}
output

11111