Solved

printf format specification for types....

Posted on 1997-10-29
1
355 Views
Last Modified: 2013-11-20
i saw the format specification of  printf, but i don't know which type is for which ...  like %f is for float right?
i'm trying to use the string.format to be used in my sql statement...  i get the values from a table in a database...and these are the types that i get from odbc...
   
types when binded using odbc
    TEXT------------------------ text
    LONGTEXT-------------------- text
    Currency-------------------- text
    Long------------------------ long
    Counter--------------------- long
    Bit------------------------- Bool
    Datetime-------------------- DateTime
    LongBinary------------------ text

if float is %f ,  long is %_? or datatime is % ?  the string fomat is supposed to be the same as those of printf, it's supposed to convert the said types to string, i just don't know which letters to use...

0
Comment
Question by:mallow
1 Comment
 
LVL 1

Accepted Solution

by:
kburns102197 earned 10 total points
Comment Utility
The following is the printf Formatting

% [flags] [width] [.precision] [{F | N | h | l | L}] type

The formats for the printf family of functions are listed below.

Flags      
-      (left justify)
+      (prefix with sign)
blank      (prefix with blank)
#      (modifies o, x, X, e, E, f, g, G)
Prefix      
F      (far pointer)
N      (near pointer)
h      (short int)
l,L      (long int or double)
Type      
d,i      (signed decimal)
u      (unsigned decimal integer)
o      (unsigned octal integer)
x,X      (unsigned hex integer)
f      (fixed-point integer)
e, E      (scientific notation)
g, G      (%e or %f; whichever is shorter)
c      (single character)
s      (string)
p      (pointer)
n      (character count)

TEXT------------------------ text  -> use %s
LONGTEXT-------------------- text  -> use %s
currency-------------------- text  -> use %s
Long------------------------ long  -> use %ld
Counter--------------------- long  use %ld
Bit------------------------- Bool -> %d
Datetime-------------------- DateTime ? probably %s
LongBinary------------------ text -> use %s


Example:
char longtext[255];

printf("This is my longtext %s",longtest);
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 86
no14 challenge 14 56
Execute multiple curl cmds with sleep and send output to file 10 80
mapAB Challlenge 35 84
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now