dimanche 28 juin 2015

Ways to print a string of an array

#include <stdio.h>

int main(){
    char arr[] = "HelloWorld";

    printf("%s\n", arr+3); //first line
    printf("%s\n", &arr[4]); //second line
    return 0;
}

Can anyone explain to me the following?

1) why is the output of first line = loWorld?

2) Why is the output of second line = oWorld?

3) Why is there a need to put & in second line?

Aucun commentaire:

Enregistrer un commentaire