version 1
char *cad1="hell";
char *cad2="home";
int j;
cad2=cad1;
for (j=0;j<4;j++){
printf("%c",cad1[j]);
}
cad2[0]='a';
for (j=0;j<4;j++){
printf("%c",cad2[j]);
}
version 2
char cad1[]="hell";
char cad2[]="home";
int j;
cad2=cad1;
for (j=0;j<4;j++){
printf("%c",cad1[j]);
}
cad2[0]='a';
for (j=0;j<4;j++){
printf("%c",cad2[j]);
}
version 3
char cad1[]="hell";
char *cad2="home";
int j;
cad2=cad1;
for (j=0;j<4;j++){
printf("%c",cad1[j]);
}
cad2[0]='a';
for (j=0;j<4;j++){
printf("%c",cad2[j]);
}
The question that I have is why version 1 hangs the dev c++?, version 2 says there is an incompatible assignment in cad2=cad1? and why version 3 works normal?