Who can find the hidden error of this bad applet?

Source: Internet
Author: User
Who can find the hidden error of this bad applet-Linux general technology-Linux programming and kernel information. The following is a detailed description. # Include
# Include

# Include
# Inlcude
# Include


Main (int argc, char * argv [])

{

Int val, m;

Char buf [18] = "hellow my world ";

Char auf [18];

If (argc! = 2) {printf ("please put one file name"); exit (1 );}

If (val = open (argv [1], O_RDWR | O_EXCL | O_CREAT, S_IRWXU) <0) {printf ("open error"); perror ("dd ");}
If (m = write (val, buf, 14 )! = 14) exit (1); printf ("% d", m );

If (lseek (val, 0, SEEK_SET) =-1) {printf ("lseek erron"); perror ("dd ");}

M = read (val, auf, 14 );

Auf [m] = \ 0;
Printf ("zzzzzzz % szzx \ n: s", auf );

If (lseek (val, 2L, SEEK_SET) =-1) {printf ("lseek erron"); exit (-1 );}

If (read (val, auf, 18) <0) {printf ("read error"); exit (-1 );}

Printf ("% s", auf );
Close (val );
Unlink ("./argv [1]");

}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.