/* * strings.c * * Created on: Mar 17, 2014 * Author: carola */ #include void strcpy_1(char *out, char *in){ int i=0; while(in[i]!='\0'){ out[i]=in[i]; i++; } out[i]='\0'; } void strcpy_2(char *out, char *in){ while(*out++ = *in++); //*out = *in; // out++; //in++; } int main(){ char *word = "hello"; //char anotherWord[8]={104,'e','l','l','o','\0','a','b'}; char anotherWord[8]={104,'e','l','l','o','\0'}; printf("word=%s\n",word); printf("anotherWord=%s\n",anotherWord); char someString[10]; strcpy_1(someString,word); printf("someString=%s\n",someString); char someString2[10]; strcpy_2(someString2,word); printf("someString2=%s\n",someString2); return 0; }