Thread: regarding file write

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    90

    regarding file write

    i need a data in the following format
    1 "one"
    2 "two"
    but iam unble to this
    ima getting
    1 one
    2 two
    my code
    fprintf(f1,"1""one");
    fprintf(f1,"2""two");
    how we can write double quotations in file
    thank u
    sree

  2. #2
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    You might wanna try :

    Code:
      fprintf(f1,"%s","1 \" one \" ");
    In the middle of difficulty, lies opportunity

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    In other words, to include a literal " character in a double quoted string, escape it with \":
    Code:
    printf("printf(\"Hello, World!\\n\");");  /* prints printf("Hello, World!\n"); */
    As you can see, you can also print backslashes (\) with \\. You can also print single quotes (') with \', though you only need to escape single quotes inside single quotes:
    Code:
    putchar('\'');
    Using single quotes in double quoted strings or vise versa without escaping is perfectly all right.
    Code:
    putchar('"');
    printf("'");
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM