Solved

printf format specification for types....

Posted on 1997-10-29
1
364 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
kburns102197 earned 10 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 99
Expand macro to ask for filename column 8 40
how to split multiple lines delimiter : 8 132
Making an alias 7 121
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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