printing a string

This is a discussion on printing a string within the C Programming forums, part of the General Programming Boards category; Dear all: I am trying to print a string in a file using the following: fprintf(input, "EXTN=`date +\"\%A_H_M_S\"`\n"); and getting ...

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    1

    printing a string

    Dear all:

    I am trying to print a string in a file using the following:

    fprintf(input, "EXTN=`date +\"\%A_H_M_S\"`\n");

    and getting the following :

    EXTN=`date +"0X0.0000000000001P-1022_H_M_S"`

    Why am I getting this? and how can I have "%A" in my string?

    Regards,

    wei

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you want to print a literal percent sign, you need to use %% (just as you need to use \\ to get a literal backslash).

    %A means "print a floating point number in hexadecimal scientific notation format".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem printing string
    By gkoenig in forum C Programming
    Replies: 4
    Last Post: 05-04-2008, 11:01 PM
  2. printing a string from a pointer
    By zmaker5 in forum C Programming
    Replies: 9
    Last Post: 07-29-2007, 09:56 PM
  3. printing string from file
    By CynthiaRullan in forum C Programming
    Replies: 7
    Last Post: 07-15-2007, 10:28 PM
  4. seg fault when printing string
    By ccoder01 in forum C Programming
    Replies: 6
    Last Post: 04-23-2004, 06:30 AM
  5. printing a string
    By ktntech in forum C Programming
    Replies: 1
    Last Post: 01-24-2002, 05:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21