I'd like to know the different ways for initializing an Array in C, because i'm having a little problem when trying to do something...
Im starting programming in C in college, its the first language, and we are viewing pointers and some functions.
That said, I was trying the following:
#include <stdio.h>
int main () {
char a[][10] = {"Hola","Chau"};
char b[][10] = {*a[0],*a[1]};
printf("Contenido de &a es: %s \n",&a);
printf("Contenido de &b es: %s \n",&b);
system("pause");
}
Which is copying what is inside a[0][0 ... 10] but wont work... at least in MS VS 2010 that is what we use at college.
So I'd like to know a link to a reference of the different ways possibles for initializing an array.
Searching here in stack, I've found the memcpy function and this work this way.
#include <stdio.h>
int main () {
char a[5] = {"Hola"};
char b[5];
memcpy(b,a,3); /* testing */
b[3] = '\0'; /* testing */
printf("Contenido de &a es: %s \n",&a);
printf("Contenido de &b es: %s \n",&b);
system("pause");
}