Welcome Guest.

1Answers

C language FOPEN why can’t I open?

Asked by: Ryan Thompson 52 views IT February 26, 2022

#include #include int main () {INT i; file * fp; char STR [20]; if ((fp = fopen ("D: \\ myfile", "R +")) == null) {Printf ("file open failed! \ N"); exit (0);} fgets (STR, 10, fp); for (i = 0; i <9; i ++) {STR [i] = STR [I] +32;} FPUTS (STR, FP); RETURN 0;}

1 Answers

  1. +3Votes  

    If you are a file opening failure!, you will show your D: The root directory doesn’t have this file (you want to build one)

    But you can’t get the result of the result you want.

    First R + open file, if you want to write, you should add

    fseek command, otherwise you cannot write

    second, you use FPUTS (STR, fp); your STR does not have the end of \ 0, to overflow.

    Reference

    I use FSEEK (FP, -1, 0);, it is the top 10 letters of the original file bySmall write to uppercase and put it behind the original file.

    Justin Clark- February 26, 2022 |