Next: Pointer -
Up: Pointer-Arithmetik
Previous: Pointer +
int
(forts.)
char *strcpy(char *s1, const char *s2) { char *tmp = s1; while (*s2 != '\0') *(tmp++) = *(s2++); *tmp = '\0'; return(s1); } main(int argc, char **argv) { char u[255]; if (argc != 3) { cerr << "Usage: " << argv[0] << ": string1 string2" <<endl; exit(1); } cout << strcmp(argv[1], argv[2]) << endl; strcpy(u, argv[1]); cout << u << endl; }
© 1997 Gottfried Rudorfer, C++-AG, Lehrveranstaltungen, Abteilung für Angewandte Informatik, Wirtschaftsuniversität Wien, 3/19/1998 |