Thread: file name input

  1. #1
    Registered User shubham's Avatar
    Join Date
    May 2011
    Posts
    14

    file name input

    how can i take input of a file's name?

  2. #2
    Registered User Inanna's Avatar
    Join Date
    May 2011
    Posts
    69
    You mean from the user?
    Code:
    char filename[BUFSIZ];
    
    printf("Enter file name: ");
    fgets(filename, BUFSIZ, stdin);
    
    FILE* fp = fopen(filename, mode);

  3. #3
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    You might want to strip the newline if any.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Input File to Output File
    By ejiroy in forum C++ Programming
    Replies: 1
    Last Post: 04-26-2009, 11:40 PM
  2. linking file stream with input file?
    By flamehead144 in forum C Programming
    Replies: 8
    Last Post: 02-07-2009, 08:55 PM
  3. file input and file pointer problem
    By drater in forum C Programming
    Replies: 6
    Last Post: 02-18-2008, 10:43 AM
  4. Input-Output File--Can't create a file...
    By zaracattle in forum C++ Programming
    Replies: 10
    Last Post: 10-18-2006, 10:15 AM