Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

printf format specification for types....

Posted on 1997-10-29
1
Medium Priority
?
367 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 30 total points
ID: 1309064
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

926 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