Help about fopen,fscanf,fprintf

This is a discussion on Help about fopen,fscanf,fprintf within the C Programming forums, part of the General Programming Boards category; The book doesn't explain well about fopen, fscanf, and fprintf and now I'm more confused... can somebody give me some ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4

    Question Help about fopen,fscanf,fprintf

    The book doesn't explain well about fopen, fscanf, and fprintf and now I'm more confused... can somebody give me some URL of C not C++ reference that explains well about this functions and that has examples 2 not a confusing examples. Please help. Thanks in advance.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    PHP Code:
    char myString[]="This is sample data.";

    fscanf(stdin"%s" myString);

    /// "stdin" is the keyboard *stream* ///

    FILE *file_ptr;  //declare a pointer to a new struct of "FILE" type

    file_ptr fopen("c://myData.txt""w+");

    fprintf(file_ptr"%s"myString);

    fclose(file_ptr); //NEVER FORGET TO DO THIS!! 
    Now look in your computer and find the file and open it.

    Check to see if it performed properly.

    Better yet, now use fscanf() with file_ptr as the *stream* and print the files contents to your screen using fprintf with "stdout" as the *stream*.
    ///"stdout" is your computers screen *stream*
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21