well.. i could not understand the need of copystring function in your program.
you are using two pointer to char type of variables. when we deal with pointers then this could be done by = operator..
try this one.
#include <stdio.h>
int main(){
char* string1="Hello World!!";
char* string2;
printf("string1: %s\n",string1);
printf("Copying string1 to string2....\n");
string2 = string1;
printf("Now string2:%s\n",string2);
return 0;
}
or if you just want your program to work then try this code
#include <stdio.h>
#include <stdlib.h>
void copyString(char*,char**);
int length(char*);
int main(){
char* string1="Hello world!!";
char* string2;
printf("string1: %s\n",string1);
printf("Copying string1 to string2....\n");
copyString(string1, &string2);
printf("Now string2: %s\n", string2);
return 0;
}
void copyString(char* string1, char** string2){
char *temp = (char*) malloc(sizeof(char) * length(string1));
do{
*temp = *string1;
string1++;
temp ++;
}while( *string1 != '\0');
*temp = '\0';
*string2 = temp;
}
int length(char* string){
int i;
for(i=0;string[i]!='\0';i++);
return i;
}