#include<iostream>
using std::cout;
using std::endl;
void copy1(char*, const char*);
void copy2(char*, const char*);
int main()
{
char string1[10];
char string2="Hello";
char string3[10];
char string4="Goodbye";
copy1(string2, string1); //copy string1 into string2
cout<<"string1="<<string1<<endl;
copy2(string4, string3); //copy string3 into string4
cout<<"string3="<<string3<<endl;
return 0;
}
void copy1(char*s2, const char*s1)
{
for(int i=0; (s1[i]=s2[i])!='\0',i++);
}
void copy2(char*s2, const char*s1)
{
for(;(*s2=*s1)!='\0'; s1++, s2++);
}
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIHN0ZDo6Y291dDsKdXNpbmcgc3RkOjplbmRsOwogCnZvaWQgY29weTEoY2hhciosIGNvbnN0IGNoYXIqKTsKdm9pZCBjb3B5MihjaGFyKiwgY29uc3QgY2hhciopOwppbnQgbWFpbigpCnsKICAgIGNoYXIgc3RyaW5nMVsxMF07CiAgICBjaGFyIHN0cmluZzI9IkhlbGxvIjsKICAgIGNoYXIgc3RyaW5nM1sxMF07CiAgICBjaGFyIHN0cmluZzQ9Ikdvb2RieWUiOwogICAgCiAgICBjb3B5MShzdHJpbmcyLCBzdHJpbmcxKTsgLy9jb3B5IHN0cmluZzEgaW50byBzdHJpbmcyCiAgICBjb3V0PDwic3RyaW5nMT0iPDxzdHJpbmcxPDxlbmRsOwogICAgY29weTIoc3RyaW5nNCwgc3RyaW5nMyk7IC8vY29weSBzdHJpbmczIGludG8gc3RyaW5nNAogICAgY291dDw8InN0cmluZzM9Ijw8c3RyaW5nMzw8ZW5kbDsKICAgIHJldHVybiAwOwp9CnZvaWQgY29weTEoY2hhcipzMiwgY29uc3QgY2hhcipzMSkKewogICAgZm9yKGludCBpPTA7IChzMVtpXT1zMltpXSkhPSdcMCcsaSsrKTsKfQp2b2lkIGNvcHkyKGNoYXIqczIsIGNvbnN0IGNoYXIqczEpCnsKICAgIGZvcig7KCpzMj0qczEpIT0nXDAnOyBzMSsrLCBzMisrKTsKfQ==
Main.java:1: error: illegal character: '#'
#include<iostream>
^
Main.java:1: error: class, interface, or enum expected
#include<iostream>
^
Main.java:3: error: class, interface, or enum expected
using std::endl;
^
Main.java:5: error: class, interface, or enum expected
void copy1(char*, const char*);
^
Main.java:6: error: class, interface, or enum expected
void copy2(char*, const char*);
^
Main.java:7: error: class, interface, or enum expected
int main()
^
Main.java:10: error: class, interface, or enum expected
char string2="Hello";
^
Main.java:11: error: class, interface, or enum expected
char string3[10];
^
Main.java:12: error: class, interface, or enum expected
char string4="Goodbye";
^
Main.java:14: error: class, interface, or enum expected
copy1(string2, string1); //copy string1 into string2
^
Main.java:15: error: class, interface, or enum expected
cout<<"string1="<<string1<<endl;
^
Main.java:16: error: class, interface, or enum expected
copy2(string4, string3); //copy string3 into string4
^
Main.java:17: error: class, interface, or enum expected
cout<<"string3="<<string3<<endl;
^
Main.java:18: error: class, interface, or enum expected
return 0;
^
Main.java:19: error: class, interface, or enum expected
}
^
Main.java:22: error: class, interface, or enum expected
for(int i=0; (s1[i]=s2[i])!='\0',i++);
^
Main.java:23: error: class, interface, or enum expected
}
^
Main.java:26: error: class, interface, or enum expected
for(;(*s2=*s1)!='\0'; s1++, s2++);
^
Main.java:26: error: class, interface, or enum expected
for(;(*s2=*s1)!='\0'; s1++, s2++);
^
Main.java:27: error: class, interface, or enum expected
}
^
20 errors