Thread: newbie reading a file..how? plz help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Be aware that a backslash in a character constant or a string literal introduces an escape sequence. Common examples are '\n' for a newline and '\t' for a tab.

    So for #2, your example is not correct.
    Code:
    FILE *fpData=fopen("c:\pj.dat","r");
    To have a backslash in the string literal, it would be coded as follows.
    Code:
    FILE *fpData=fopen("c:\\pj.dat","r");
    Note that this is for string literals as in your case #2. You wouldn't need to enter two backslashes for user input as in case #3. That is to say at the command line you could do something like the following.
    Code:
    Please enter the path: c:\pj.dat
    Last edited by Dave_Sinkula; 04-09-2003 at 12:58 PM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Replies: 7
    Last Post: 02-02-2009, 07:27 AM
  3. sequential file help plz
    By dutrachr in forum C Programming
    Replies: 4
    Last Post: 04-18-2006, 11:41 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM