Solved

printf format specification for types....

Posted on 1997-10-29
1
365 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

621 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