Duke wrote:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> int main(int argc, char *argv[])
> {
> char *s = "hello strlen";
> printf("%s has %d chars.\n", s, strlen(s));
> //the above strlen function execute correctly
> char *msg1 = "abcdefghijklmnopqrstuvwxyz";
>
> char buf[10];
>
> strcpy(buf, msg1);
Your program has involved undefined behaviour here. buf is not
large enough. In addition, unless you have a C99 compiler, the
declaration of buf is invalid. Move it up after the declaration of
s.
> printf("[%s] length: %d\n", msg1, strlen(msg1));
> //but the above statement will throw a runtime os exception
> system("PAUSE");
This may or may not do anything.
> return 0;
> }
>
> I don't know what occus after I find all the resource about c which I
> can find.
Also, without a C99 compiler, the // comments may be illegal.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
--
Posted via a free Usenet account from
http://www.teranews.com