Thread: File i/o filename its extension

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Registered User
    Join Date
    Jan 2012
    Posts
    25
    Quote Originally Posted by CommonTater View Post
    Seriously?

    Code:
    char filename[256];
    
    // put client's filename in filename[]
    
    
    fp = fopen(filename,"w");
    Seems pretty obvious...
    I understood that part, i know i have to do the folowing:

    Code:
    char filename[10];
    scanf("%s", filename);
    FILE *fp = fopen(filename, "w" );

    But that is not my problem, my problem is how do i extract the second string from the buffer. The second string is just the name of the file (test.txt), you can see that on my previous post when i print the buffer. I have a buffer
    Code:
    char *buffer = malloc(BUFFSIZE);
    . that buffer i use for my protocol en for the data to be saved. The question is how do i specifie the filename from that buffer. How do i link those two with each other? I just dont see it.

    Code:
    scanf("%s %s", &buffer);
    Last edited by Alix; 01-17-2012 at 12:49 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 01-11-2012, 04:56 AM
  2. Changing filename extension
    By slippy in forum C Programming
    Replies: 3
    Last Post: 05-03-2007, 11:04 AM
  3. Getting a File Extension?
    By Nebbuchadnezzar in forum C++ Programming
    Replies: 3
    Last Post: 09-27-2006, 12:45 PM
  4. Replies: 6
    Last Post: 04-11-2006, 04:52 PM
  5. allow another file extension??
    By C+noob in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-03-2005, 08:52 PM