EmbeddedRelated.com
Forums

Sprintf unsigned long conversion specifier

Started by johnpititto1976 September 24, 2003
Hi All,

I want to convert a unsigned long to a string. What is the conversion
specifier to use for the codewarrior compilier??

Thanks,

John.



Hello, John

I Tried that code, and its OK (send to a Lcd display).
Code Warrior version 4.2.6.895
--> "%u" for "unsigned int" (u means unsigned)
--> "%lu" for "long unsigned".

Joel

//
#include <stdio.h>
.../...
char s[80];
unsigned long z;
unsigned int i;

Lcd_Init (); // init my Lcd display

z = 1234567895;
i = 65432;
sprintf (s, "%u %lu", i, z);
Lcd_Puts (s); // send string to my Lcd display ----- Original Message -----
From: johnpititto1976
To:
Sent: Thursday, September 25, 2003 5:09 AM
Subject: [68HC12] Sprintf unsigned long conversion specifier Hi All,

I want to convert a unsigned long to a string. What is the conversion
specifier to use for the codewarrior compilier??

Thanks,

John.