Thread: opening a file

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    6

    opening a file

    hi. in a variable name I have the name of a file. how can I open it?
    Code:
    char name[14]="name.bmp"; 
    FILE *image=fopen(name, "rb");
    this doesn' t work. it shows me "segmentation fault". why?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    The problem probably lies elsewhere.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 11-30-2011, 12:49 AM
  2. About file opening
    By kira_coder in forum Windows Programming
    Replies: 5
    Last Post: 03-14-2010, 11:15 PM
  3. Opening a file
    By shaun84 in forum C Programming
    Replies: 5
    Last Post: 10-29-2005, 04:08 PM
  4. opening a file in dos
    By makveli in forum C++ Programming
    Replies: 6
    Last Post: 11-12-2003, 04:42 PM
  5. opening a file in DOS
    By alanair23 in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 12-19-2002, 09:02 PM

Tags for this Thread