Thread: Simple C Question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    13

    Simple C Question

    How can i open a file for reading and writing in a directory other than "C:\"??

    This is the only way I know how to do this...


    Code:
    if((fp = fopen("C:\hello.txt, "w")) != NULL)
    {
         
         fprintf(fp, "Hello.");	
         fclose(fp);
    
    }
    
    else
         puts("Write Failed.");
    So when I do that all i can read and write are files in C:\ and no other directory...like C:\whatever...if i try that it fails. To clarify, If i were to write C:\directory\text.txt in up there, it fails. I also tried C:\\directory\\text.txt but that fails too.

    Thanks.
    Last edited by almo89; 02-10-2006 at 11:44 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM