Arista Networks Interview Question

What is the functional difference between these two declarations: char * string1="string"; char string2[]="string";

Interview Answers

Anonymous

Jun 26, 2016

string1 is just a string literal that is allocated as read only, so it can't be changed. string2 is just an allocated array of characters, that can be changed. This only holds true for char * . Compiler magic at its finest.

1

Anonymous

May 13, 2016

for the first, we need allocate an extra space to hold the pointer string1