[ create a new paste ] login | about

Link: http://codepad.org/soO0Np2A    [ raw code | output | fork ]

C, pasted on Sep 9:
#include <stdio.h>
#include <string.h>

void printArray(char arr[], int n)
{

    for(int i=0; i<n; i++) {
        printf("%c - ", arr[i]);
    }
    printf("\n");
}

int main()
{
    int n = 10;
    char arr[10] = "Shirley";

    printArray(arr, n);
    printf("Array before memset() arr %s and sizeof(arr) %d strlen(arr) %d\n", arr, sizeof(arr), strlen(arr));
    // Fill whole array with 0.
    memset(arr, '\0', sizeof(arr));
    printf("Array after memset()\n");
    printArray(arr, n);
    
    return 0;
}


Output:
1
2
In function 'printArray':
Line 7: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: