Thread: Unable to open a file for reading

  1. #16
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Since it doesn't compile, I would say no.

    Also, str needs to be an array. You can't read 20 chars into a buffer of size 0. BTW, if the file doesn't exist, why try to print the array?

  2. #17
    Registered User
    Join Date
    Oct 2001
    printf("%s",str); should be inside the braces. same with fclose. Follow the program flow for if the file fails to open. str will be uninitialized.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Unable to open include file SDL_audio.h
    By in forum C Programming
    Replies: 2
    Last Post: 06-28-2008, 08:04 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM