The fopen function in Codeblocks does not support the command "R"

Source: Internet
Author: User

Codeblocks

#include <stdio.h>

#include <stdlib.h>

void Main (void)

{

FILE *fp=null;

if ((fp=fopen ("Shuju.txt", "R")) ==null)

{

printf ("Can not open the file! \ n ");

Exit (0);

}

Fclose (FP);

return (0);

}

Run this program, always print out "Can not open the file!", in various forums and Baidu a bit, no fruit.

Constantly useless to try, the "R" is rewritten as "r+", the problem of unreadable files can be resolved.

Finally, the problem is solved, but why is the "R" Operation not supported in the Codeblocks programming environment? The same statement is compiled under vc6.0 and can read the file normally.

The fopen function in Codeblocks does not support the command "R"

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.